Gridview, database and count [Resolved]

Posted by Sina under ASP.NET on 6/6/2012 | Points: 10 | Views : 1238 | Status : [Member] | Replies : 3
Hi i have a doubt..i have a table in which there is a field 'city' which stores user input from dropdown list..due to which it cannot be made 'unique' or 'distinct'. coming to the topic..i need a gridview which displays the cities and the corresponding count as to how many times the particular city appears in the db.Pl help me..i have included gridview bt got stuck up on how to implement the remaining logic..pl help

@Sina


Responses

Posted by: Somasundaram on: 6/6/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
hi

Refer this link
http://www.java2s.com/Code/Oracle/Aggregate-Functions/GetthenumberofrowsineachcitygroupusingtheCOUNTfunction.htm

Regards,
Somasundaram

Sina, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ajay.Kalol on: 6/6/2012 [Member] Starter | Points: 25

Up
0
Down
You Have a two table,
1. City
- ID
- Name
2. Info
- ID
- Name
- CityID

In Info table Many time Same City may be entered.
ok.

To Get Count of City in Info Table And City name Write Following query

SELECT C.NAME,COUNT(CITYID) FROM info LEFT OUTER JOIN City C on info.CityID = C.ID

Group by C.Name


Ajay
ajaypatelfromsanthal.blogspot.in

Sina, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sina on: 6/7/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks a lot for the responses :)

@Sina

Sina, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response