| 1 | -- select status,count(*) from oi group by status
|
|---|
| 2 |
|
|---|
| 3 | --select ord.site,cat,count(*) from ord,oi,coop where ord.orno=oi.orno and ord.final=coop.cno and ortype in ('DI','RP') and
|
|---|
| 4 | --oi.status in ('INSPECT','PSHIP','SHIPPED') and cast(oi.acted as date) between '01-01-2015' and '12-31-2015' group by ord.site,cat order by 1,2
|
|---|
| 5 | --select ord.site,cat,count(*) from ord,oi,coop where ord.orno=oi.orno and ord.final=coop.cno and ortype in ('DI','RP') and
|
|---|
| 6 | --oi.status in ('INSPECT','PSHIP','SHIPPED') and cast(oi.acted as date) between '01-01-2015' and '12-31-2015' group by ord.site,cat order by 1,2
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 | select * from
|
|---|
| 10 | (
|
|---|
| 11 | select ord.site,cat,ISNULL(COUNT(*),0) XCOUNT
|
|---|
| 12 | from ord,oi,coop where ord.orno=oi.orno and ord.final=coop.cno and ord.ortype in ('DI','RP') and
|
|---|
| 13 | oi.status in ('INSPECT','PSHIP','SHIPPED') and year(oi.acted) = 2018 group by ord.site,caT
|
|---|
| 14 | ) src
|
|---|
| 15 | pivot
|
|---|
| 16 | (
|
|---|
| 17 | sum(xcount)
|
|---|
| 18 | for cat in ([UARS], [UFED], [STA], [UCOM], [UPRU] , [UIND], [UAID], [INT], [FGEN], [FCOM], [FPRU], [FIND])
|
|---|
| 19 |
|
|---|
| 20 | ) piv; |
|---|