Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Count WHERE...howto?


Message #1 by "SD-Studios" <info@s...> on Sat, 10 Nov 2001 16:49:27 +0100
If I have a field in a table that is called genre. Now I want to count how

many games that is in each genre.

How do I count this? Do I do it like e.g. SELECT Count(genre) FROM mytable

WHERE genre = '" & Request.QueryString("genre") & "'? Or how do I count?

--

Martin Johansson



Message #2 by Imar Spaanjaars <Imar@S...> on Sat, 10 Nov 2001 16:52:04 +0100
You can use Count(*) or Count(ID) where ID is the unique ID for your table.



Beware for unexpected results: Count(*) includes null values, where as 

Count(columnName) only returns non-null values.



In the above example, if ID is the primary key for the table, there 

wouldn't be a difference between Count(*) and Count(ID) as there shouldn't 

be any NULL values in the ID column.



Hope this helps,



Imar





At 04:49 PM 11/10/2001 +0100, you wrote:

>If I have a field in a table that is called genre. Now I want to count how

>many games that is in each genre.

>How do I count this? Do I do it like e.g. SELECT Count(genre) FROM mytable

>WHERE genre = '" & Request.QueryString("genre") & "'? Or how do I count?

>--

>Martin Johansson

>

>

>









  Return to Index