Home > database >  SQL query conditions and more output, consult
SQL query conditions and more output, consult

Time:09-18

Have two data in a data table
A personnel data traffic data tables, a traffic channel is the level of report
Need according to have an idea now

Want to query out a certain level of all the number of gate within the prescribed time,

Select count (*) FROM th_event_info
WHERE event_time BETWEEN '00:32:13' 2019-09-23 and '2019-09-25 23:32:13'
And the event_type='1'
And reader_id='0001'
From A table query can pass statement query statistic number of A kind of level, requires human to replace reader_id value individually (400 +)

But the body of the reader_id numerical is actually in the B in the table, and there are a lot of article, what method can directly output the following results?

The final output is the result of the
Number of name
0001, 100,
56 0003
0004




CodePudding user response:

 select reader_id, COUNT (*) FROM th_event_info 
WHERE event_time BETWEEN '00:32:13' 2019-09-23 and '2019-09-25 23:32:13'
And the event_type='1'
GROUP BY reader_id