Tam
|
| Posted: 09/15/2005, 1:48 PM |
|
Hi there,
I have used 2 sql statement in my grid:
1) SELECT ip FROM stats GROUP BY ip ORDER BY ip
2) SELECT DISTINCT ip FROM stats ORDER BY ip
Both give the same results. The grid of statement #2 works fine; howerver, in case (1), the TotalRecords label and the navigator don't work.
If anyone knows why, please explain why CCS is like that. Equally important, can you tell me the differences between these 2 sql statements?
Thanks very much.
|
|
|
 |
Ajazza
|
| Posted: 09/15/2005, 1:59 PM |
|
Distinct will only bring back one occurence of the IP, so for example in the following...
192.168.0.1
192.168.0.4
192.168.0.1
Your 2nd statement will return:
192.168.0.1
192.168.0.4
Whereas your first statement would return
192.168.0.1
192.168.0.1
192.168.0.4
Cheers
Adam
|
|
|
 |
peterr
Posts: 5971
|
| Posted: 09/15/2005, 2:05 PM |
|
As for CCS, in some cases CCS is just unable to figure out a proper COUNT SQL statement that will count the total number of returned records. In those cases you can use the CountSQL property of the datasource to specify the proper SQL for counting records. See some past discussions on the subject at http://forums.codecharge.com/search.php?s_keyword=Count...g=2&s_forum[]=5
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Tam
|
| Posted: 09/16/2005, 10:06 AM |
|
Adam,
I don't think your statement is correct since BOTH sql statments give the same result.
Peter,
I found a message from dsafar in http://forums.codecharge.com/posts.php?post_id=60805&s_keyword=CountSQL, and he said countsql doesn't work with GROUP BY. I think that is why the TotalRecords and navigator don't work correctly. I need to modify it then.
Thanks.
|
|
|
 |
Gabriele Persia
|
| Posted: 09/29/2005, 8:46 AM |
|
GROUP BY should be used to apply aggregate operators to each group (the result of the query may have many of them). If all you need is to remove duplicates (missing or "weak" WHERE clause) then use DISTINCT.
So maybe what Adam means is that the two statement should not be used intercheangebly.
Hope this helps.
Gabriele
|
|
|
 |
|