Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SELECT COUNT(*) SQL SERVER

I have this:

SELECT AssignmentID
FROM ProblemView
GROUP BY AssignmentID

which returns 32 rows. But really what I want is the number 32. If I do this:

SELECT COUNT(*)
FROM lru.ProblemView
GROUP BY AssignmentID

I still get 32 rows, and the column is merely the count of the number of Assignments per problem.

I just need the number 32.

like image 405
Phillip Senn Avatar asked Jan 02 '11 00:01

Phillip Senn


People also ask

What does select COUNT (*) mean in SQL?

COUNT(*) returns the number of rows in a specified table, and it preserves duplicate rows. It counts each row separately. This includes rows that contain null values.

What is COUNT (*) used for?

The COUNT(*) function returns the number of rows in a dataset using the SELECT statement. The function counts rows with NULL, duplicate, and non-NULL values. You can also use the WHERE clause to specify a condition.

What does COUNT (*) SQL function return?

The COUNT() function returns the number of rows that matches a specified criterion.

What is the use of COUNT () and COUNT (*) in SQL?

COUNT() With NULL ValuesSELECT COUNT(*) returns the count of all records in the result set regardless of NULL values. SELECT COUNT(attribute) returns the count of records containing non-NULL values of the specified column.


1 Answers

SELECT count(distinct AssignmentID) 
FROM ProblemView 
like image 63
D'Arcy Rittich Avatar answered Nov 04 '22 04:11

D'Arcy Rittich