sql - Access Query - Select count distinct per record on multiple tables -


i have query (concatenated inside vb string):

select a.table_no tbl, count(b.table_no) total_call_count,        avg(timevalue(c.service_time) * 86400) total_time table_button_link a, button_log b, service_time_log c  b.table_no = c.table_no   , format(b.transaction_datetime,""dd/mm/yyyy"") = '" & date.now.tostring("d") & "' "  , b.type <> 2 , b.table_no = a.table_no , c.table_no = a.table_no  group a.table_no 

i want count tbl_no table button_log returns this:

|tbl_no  | total_call_count | total_time | |   1    |      4661        |   7.2134   | |   2    |       5          |     3      | |   3    |      576         |   9.33333  | 

my desired output this:

|tbl_no  | total_call_count | total_time | |   1    |       5          |   7.2134   | |   2    |       1          |     3      | |   3    |       3          |   9.33333  | 

button_log looks this:

| id | table_no | type | transaction_datetime    | | 1  |   1      |  1   | 28/07/2017 10:41:34  | | 1  |   1      |  2   | 28/07/2017 10:42:22  | | 2  |   1      |  1   | 28/07/2017 10:42:25  | | 3  |   2      |  1   | 24/07/2017 10:41:47  | 

table_button_link this:

| id | table_no | button_no | | 1  |   1      |   1       | | 2  |   2      |   2       | 

and service_time_log :

| id | table_no | service_time | transaction_date       | | 1  |    1     |  00:00:04    | 28/07/2017 10:42:22 | | 1  |    2     |  00:00:05    | 28/07/2017 10:50:43 | 

i think counts records. tried using count(distint b.table_no) guess ms access can't that. how achieve this? please help. thanks.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -