Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Sql select count and distinct...

Posted on 2011-03-06
4
Medium Priority
?
450 Views
Last Modified: 2012-05-11
I have this query which returns car manufacturers...
SELECT DISTINCT [Make] FROM [VehicleSpecs] ORDER BY [Make]

How can I modifiy this query to also return the count for each make?

0
Comment
Question by:evo_x
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:derekkromm
ID: 35051333
SELECT [Make],count(*) FROM [VehicleSpecs] group by [Make] ORDER BY [Make]
0
 
LVL 2

Author Comment

by:evo_x
ID: 35051377
But how can I assign a field name to count ? because this way I can't assign the count field to the asp.net control.
0
 
LVL 15

Accepted Solution

by:
derekkromm earned 2000 total points
ID: 35051417
SELECT [Make],count(*) as [MakeCount] FROM [VehicleSpecs] group by [Make] ORDER BY [Make]
0
 
LVL 2

Author Comment

by:evo_x
ID: 35051432
Thanks !
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question