excel - Filtering Data from a Query with SQL -
i'm running issues sql code i'm using. i've been posying this, not getting answers. tried adapt this code trying do, keep getting screen shot of error message screen grabbed below.
select loginid, shiftnumber, palletqty, group, shiftdate database count(palletqty) totalcount sum(if(group='put',1,0)) activecount, round((sum(if(tally_tran_mstr.pri_grp_cd='put',1,0))*100/count(tally_tran_mstr.full_pllt_qty)),2) pctactive wbr_rw.tally_tran_mstr tally_tran_mstr now, there many dates , many names each date, want code recognize that. i'm not sure if code i'm trying adapt able that.
i'm struggling @ point how make code work, or find code may work. appreciated. let me know if additional information needed.
i trying view data of person spent more 75% of time doing "put" specific date.
an example of i'm trying (calculated manually)
mcmillan has 3 items associated name 6/15/2017. 1 of "put". total of "put" items date him 132. sum of associated name date 167. 132/167 = 0.79. 0.79>0.75 want data show in query results. malone has 4 items associated name on 6/15/2017. 1 of "put". "put" summed 4. sum of 4 items 36. 4/36=0.11 0.11 < 0.75, want rid of data.
oracle not support if(). use proper oracle syntax. think query should more this:
select loginid, shiftnumber, palletqty, "group", shiftdate, count(palletqty) totalcount, sum(case when "group" = 'put' 1 else 0 end) activecount, round(sum(case when tally_tran_mstr.pri_grp_cd = 'put' 1 else 0 end)*100 / count(tally_tran_mstr.full_pllt_qty), 2) pctactive wbr_rw.tally_tran_mstr tally_tran_mstr group loginid, shiftnumber, palletqty, "group", shiftdate; 

Comments
Post a Comment