We help IT Professionals succeed at work.
Get Started

oracle query

anumoses
anumoses asked
on
230 Views
Last Modified: 2015-04-13
Select distinct ih.customer_id,patient_name,
           sum(id.order_qty) qty           
from       invoice_header ih,
           invoice_detail id,
           item_profile ip,
           valid_products@plab.world vp
where id.invoice_number = ih.invoice_number
and id.item_id = vp.product_code
and   id.item_id = ip.item_id
and   ip.item_type in ('P')
and customer_id = 'WAD-EX0128'
and   ih.invoice_date between  '01-JAN-2015' and '31-JAN-2015'
and vp.inv_product_type in ('RBC','LRBC','LPHER','PHER','FFP','FP24','CRYO')
group by ih.customer_id,patient_name
union all
Select distinct ih.customer_id,patient_name,
           sum(id.order_qty) qty           
from       invoice_header ih,
           invoice_detail id,
           item_profile ip,
           valid_products@plab.world vp
where id.invoice_number = ih.invoice_number
and id.item_id = vp.product_code
and   id.item_id = ip.item_id
and   ip.item_type in ('P')
and customer_id = 'WAD-EX0128'
and   ih.invoice_date between  '01-FEB-2015' and '28-FEB-2015'
and vp.inv_product_type in ('RBC','LRBC','LPHER','PHER','FFP','FP24','CRYO')
group by ih.customer_id,patient_name
union all
Select distinct ih.customer_id,patient_name,
           sum(id.order_qty) qty           
from       invoice_header ih,
           invoice_detail id,
           item_profile ip,
           valid_products@plab.world vp
where id.invoice_number = ih.invoice_number
and id.item_id = vp.product_code
and   id.item_id = ip.item_id
and   ip.item_type in ('P')
and customer_id = 'WAD-EX0128'
and   ih.invoice_date between  '01-MAR-2015' and '31-MAR-2015'
and vp.inv_product_type in ('RBC','LRBC','LPHER','PHER','FFP','FP24','CRYO')
group by ih.customer_id,patient_name

Open in new window


data
Required  

Customer id          Patient name                                         JAN        FEB         MAR
WAD-EX0128     ALEXIAN BROTHERS MEDICAL CENTER     515       442          510

Help appreciated. I tried case but did not get the correct query.
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2012
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE