|
| |
|
|
Long Island Lune
Posts: 2340 Joined: 6/8/2002 From: New York Status: offline
|
Mixing DISTINCT and COUNT in an SQL - 9/14/2002 13:35:11
To all, Does anybody know the correct SQL syntax for mixing the words DISTINCT and COUNT? I already tried these 3 (below)... They do NOT work: SELECT DISTINCT Count(' SubCategory' ) AS [Total] FROM SubCategories SELECT DISTINCT SubCategory Count(' SubCategory' ) AS [Total] FROM SubCategories SELECT DISTINCT SubCategory FROM SubCategories Count(' SubCategory' ) AS [Total] Thanks in advance... LLL
_____________________________
|
|
|
|
kvl
Posts: 61 Joined: 5/30/2002 From: Status: offline
|
RE: Mixing DISTINCT and COUNT in an SQL - 9/14/2002 14:03:30
Try SELECT COUNT(DISTINCT SUBCATEGORY) AS TOTAL FROM SUBCATEGORIES. This is how it works in SQL2000.
|
|
|
|
hhammash
Posts: 1064 Joined: 8/19/2002 Status: offline
|
RE: Mixing DISTINCT and COUNT in an SQL - 9/14/2002 16:26:09
Hi LLL, Try this: SELECT DISTINCT books.Title, books.Publisher, Count(books.Comment) AS CountOfComment FROM books GROUP BY books.Title, books.Publisher; Regards Hisham
|
|
|
|
hhammash
Posts: 1064 Joined: 8/19/2002 Status: offline
|
RE: Mixing DISTINCT and COUNT in an SQL - 9/15/2002 1:32:59
Hi LLL, Send me you .mdb file, tell me what you want and you will get it. Or Explain in details, what fields are involved, and what is the result that you need, relax and leave it to me. The sample I sent you is working fine with me and displaying one record with the count of that record. Regards Hisham
< Message edited by hhammash -- 9/14/2002 1:33:49 AM >
|
|
|
|
hhammash
Posts: 1064 Joined: 8/19/2002 Status: offline
|
RE: Mixing DISTINCT and COUNT in an SQL - 9/15/2002 13:58:40
Hi LLL, Go to the site again, I was updating it when you was viewing it. the code you want is: SELECT DISTINCT Subcategories.Subcategory, Count(Subcategories.Subcategory) AS CountOfSubcategory FROM Subcategories GROUP BY Subcategories.Subcategory; Regards Hisham
|
|
|
|
hhammash
Posts: 1064 Joined: 8/19/2002 Status: offline
|
RE: Mixing DISTINCT and COUNT in an SQL - 9/15/2002 14:20:12
No worries friend, Consider it done. Hisham
|
|
|
|
hhammash
Posts: 1064 Joined: 8/19/2002 Status: offline
|
RE: Mixing DISTINCT and COUNT in an SQL - 9/15/2002 15:21:06
Hi LLL, Please check this: http://www.fmhs.uaeu.ac.ae/nml/LLL.asp First table shows 7 records, second table shows 8 records because each one is from a different table. Don' t worry, it is not a mistake Hisham
< Message edited by hhammash -- 9/14/2002 3:22:34 PM >
|
|
|
|
Long Island Lune
Posts: 2340 Joined: 6/8/2002 From: New York Status: offline
|
RE: Mixing DISTINCT and COUNT in an SQL - 9/15/2002 18:17:47
Hisham, I just went to your site and saw your two examples. Terrific. The first one is the moneymaker for me. The 7 total was the last entry after the query. That will work. What was the SQL you used for the first example??? Thanks my friend. LLL
_____________________________
|
|
|
|
hhammash
Posts: 1064 Joined: 8/19/2002 Status: offline
|
RE: Mixing DISTINCT and COUNT in an SQL - 9/16/2002 1:11:42
Hi Mark, You are WELCOME Hisham
|
|
|
|
stu
Posts: 129 From: doylestown,pa Status: offline
|
RE: Mixing DISTINCT and COUNT in an SQL - 9/16/2002 14:19:47
Hisham, Just to let you know. Your advise also helped me with a similar issue I was having. Thank You, stu
|
|
|
|
Long Island Lune
Posts: 2340 Joined: 6/8/2002 From: New York Status: offline
|
RE: Mixing DISTINCT and COUNT in an SQL - 9/16/2002 14:22:33
stu, Hisham IS " the man" ... He' s great with date queries too.
_____________________________
|
|
|
|
hhammash
Posts: 1064 Joined: 8/19/2002 Status: offline
|
RE: Mixing DISTINCT and COUNT in an SQL - 9/16/2002 16:27:27
Hi, Thank you stu, you are welcome. LLL, thank you very much for you continuous support and appreciation. Your replies are always rewarding. Thanks a lot friend. Best regards Hisham
|
|
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
|
|
|