MySQL - JOIN data from two columns into one output -
first time posting stack, apologies if screw up.
i have table of data in mysql i'll call table1. table has time stamps when transaction goes live, , when same transaction closed out. can run 2 separate queries (seen below) generate count amount transactions created per hour (query1), , amount of transactions resolved per hour (query2) - if combine queries, can data need starting @ hour 4 (when people begin work) need data transactions created before can create comprehensive output shows our total transactions incoming (starting @ hour 0) , showing how many we're completing (starting @ hour 4).
query1
select date_format(created_at, '%h') 'hour', count(distinct(created_at)) queued
from table1
where date_format(created_at, '%m-%d-%y') = '04-02-2017'
group date_format(created_at, '%h');
query2
select date_format(resolved_at, '%h') 'hour', count(distinct resolved_at) 'worked'
from table1
where date_format(resolved_at, '%m-%d-%y') = '04-02-2017'
group date_format(resolved_at, '%h');
if run query 3, pulls right data hours 4 - 23 (when we're staffed) can't hours 0-3
query3
select date_format(resolved_at, '%h') 'hour', count(distinct resolved_at) 'worked', count(distinct created_at) 'queued'
from table1
where date_format(resolved_at, '%m-%d-%y') = '04-02-2017'
group date_format(resolved_at, '%h');
thank you! tried post example of output, couldnt formatting right.
Comments
Post a Comment