|
| |
|
|
lu lu
Posts: 418 From: wpg, mb Status: offline
|
sql with COUNT and by DISTINCT - 11/19/2003 18:58:38
the sql below is what i'm trying to do, any one know what the proper syntax for this: sql = "SELECT COUNT (id) FROM tblDOG WHERE field22 DISTINCT" // basically i want to display the number of all the unique records cheers
|
|
|
|
BeTheBall
Posts: 6365 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: sql with COUNT and by DISTINCT - 11/19/2003 20:05:52
Does this do what you need? SELECT Count DISTINCT (Field22) As CountofField22, Field22 FROM tblDOG Group by Field22
< Message edited by betheball -- 11/19/2003 8:06:47 PM >
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
lu lu
Posts: 418 From: wpg, mb Status: offline
|
RE: sql with COUNT and by DISTINCT - 11/19/2003 20:51:19
error: Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Count DISTINCT (field22)
|
|
|
|
BeTheBall
Posts: 6365 Joined: 6/21/2002 From: West Point Utah USA Status: offline
|
RE: sql with COUNT and by DISTINCT - 11/19/2003 22:12:51
Here was my original thought before some reading talked me out of it: Select Count(*) From (Select DISTINCT (Field22) From TableDog)
_____________________________
Duane Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.
|
|
|
|
rdouglass
Posts: 9272 From: Biddeford, ME USA Status: offline
|
RE: sql with COUNT and by DISTINCT - 11/20/2003 9:49:46
How about letting the query grab the unique's and letting the ASP do the count? For instance, if you're using the DRW, use a query like: SELECT DISTINCT [Field22] FROM TableDog Then, use fp_iCount to get the total (or if you're using arrays, use uBound(myArray,2). Does that help at all?
_____________________________
Don't take you're eye off your final destination. ASP Checkbox Function Tutorial.
|
|
|
|
Richard Dudley
Posts: 668 Joined: 8/22/2002 From: Butler, PA Status: offline
|
RE: sql with COUNT and by DISTINCT - 11/21/2003 23:34:41
Doesn't work with Access Jet database (would work with SQL Server). You'll need one query to select distinct, then select count in a second query. Then, select that second query from ASP.
_____________________________
I need to change my avatar--the puppy is full grown now!
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|