jeudi 4 juin 2015

counting times that a function of my server was used for each user in sqlite

I use sqlite to log every user's every access to my server. Everytime a user uses a functionality, I will append a record to the 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 for a user, fun_id stands for functionality like login/send_text/logout...

I want to know each functionality's usage, used by who and how many times, plot with gnuplot. For short, I need this for plotting:

fun_id  usr_id  used_count  // I dont' really need this line
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 three times

How to generate this with a sql query?

Thanks.

Aucun commentaire:

Enregistrer un commentaire