mysql - Merge two queries to get the combined value in SQL -


i have merge 2 sql queries values in 1 place. want show year date , week date show amounts , units in 1 table same cat

sql query

select      `empsid`, `cat`, `chk_date`,      sum(amount) currentamount,     sum(units) currentunits       `pays`       `empsid` = 'semlad01' ,      `cat` in ('salary pay', 'truck allowance', 'expense reimbursement', 'bonus  (accrued)', 'phone reimbursement') ,      date(`chk_date`) = '2016-11-12'  group      `cat` 

second query:

select      `empsid`, `cat`, `chk_date`,      sum(amount) ytdamount,     sum(units) ytdunits       `pays`       `empsid` = 'semlad01' ,      `cat` in ('salary pay', 'truck allowance', 'expense reimbursement', 'bonus  (accrued)', 'phone reimbursement') ,      date(`chk_date`) <= '2016-11-12'  group      `cat` 

table structure

 empsid       cat               ytdamount   ytdunits   currentamount     currentunit semlad01   bonus                 3000.00      0.00        0.00      0.00 semlad01   expense               1307.90      0.00       50.00      semlad01   phone reimbursement    272.00     50.00     1840.00      0.00 semlad01   salary pay           60153.74   1840.00        0.00      0.00 semlad01   truck allowance       4246.26      0.00 

     select `empsid`, `cat`, `chk_date`, sum(amount) currentamount,sum(units) currentunits       ,sum(case when date(`chk_date`) = '2016-11-12'  amount else 0 end) '2016-11-12amount' ,       ,sum(case when date(`chk_date`) = '2016-11-12'  units else 0 end) '2016-11-12units' ,     `pays` `empsid` = 'semlad01' ,      `cat` in ('salary pay', 'truck allowance', 'expense reimbursement',      'bonus  (accrued)', 'phone reimbursement')and date(`chk_date`) <= '2016-11-12'       group `cat` 

Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -