MySQL: group by hour AND by other distinct fields -


i have 'logs' table, in search results' counters stored, search query , user searched it.

my goal display results grouped hour, i'm having issues when using group because i'm losing distinct users / queries in process.

here's fiddle: http://sqlfiddle.com/#!9/484c01/7

as can see, results being count according results no. output not correct. in advance help.

there data size limits on can returned following method, if want preserve distinct row values of non-grouped-by-columns when doing group by, can use group_concat mysql function combine each row's value 1 row separated commas.

see http://dev.mysql.com/doc/refman/5.6/en/group-by-functions.html#function_group-concat usage examples.

important: sure read documentation's note on group_concat_max_len , max_allowed_packet in link provided above.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -