Solved

Sql select count and distinct...

Posted on 2011-03-06
4
440 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
  • 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 500 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

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tempdb log keep growing 7 33
SQL Server / Update DB? 22 36
install report service in sccm2012 3 17
SQL Availablity Groups List 2 7
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

839 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