sqlite - How do I count distinct combinations of column values? -
i use sqlite log every user's every access server. every time user uses function, append record database.
the database looks like:
usr_id fun_id 3 1 // user_3 used function_1 2 13 // user_2 used function_13 3 11 // user_3 used function_11 2 1 // user_2 used function_1 7 2 // ...
usr_id
stands user, fun_id
stands functions login / send_text / logout...
i want know each function's usage, used , how many times, plot gnuplot. in short, need plotting:
fun_id usr_id used_count 1 2 1 // user_2 used function_1 once 1 3 1 // user_3 used function_1 once 2 7 1 // user_7 used function_2 once 13 2 3 // user_2 used function_13 3 times
how generate sql query?
just use count(*)
along grouping:
select fun_id, usr_id, count(*) used_count tablename group fun_id, usr_id order fun_id, usr_id;
Comments
Post a Comment