SQL query with COUNT(DISTINCT
| Project: | Drupal |
| Version: | 5.1 |
| Component: | statistics.module |
| Category: | feature request |
| Priority: | normal |
| Assigned: | abautu |
| Status: | duplicate |
Hello,
I'm working on a SQLite layer for Drupal as a hobby. It's very functional, but I have the following problem: your module uses some queries with COUNT(DISTINCT(...)). I'm not sure is this syntax is SQL standard, but it can by rewritten using a GROUP BY clause (in a 100% standard way). For instance:
line 287: SELECT COUNT(DISTINCT(path)) FROM {accesslog} could be replaced with SELECT COUNT(*) FROM {accesslog} GROUP BY path
line 321: SELECT COUNT(DISTINCT(CONCAT(uid, hostname))) FROM {accesslog} could be replaced with SELECT COUNT(*) FROM {accesslog} GROUP BY uid, hostname
You may notice that the queries I'm suggesting are shorter, cleaner (you may cleary see that you are counting all the lines) and faster (notice there is no CONCAT call in the later example).
Best wishes,
Andrei.

#1
I learned how to use a CVS, how Drupal CVS works, how patches are made and I thought to give it a try. I've tested the patch on my installation.
#2
1) Do not post duplicate issues to different issue queues.
2) Do not set your own patch to "ready to be committed".
3) Do check the issue queue before posting, as there is already an effort for SQLite support: http://drupal.org/node/67349
Thank you.