I have several tables that I want to get counts from and display on a single line.
Table1: order_date, item_ordered, etc
Table2: Process_date, item_processed, etc
Table3: Shipment_date, package_count, etc
Table4: Payment_date, amount_received, etc
What I want is:
Date Order Count Processed Shipments Pmnts Rcvd
01/05 50 45 61 22
01/06 39 51 34 26
01/07 40 42 41 30
If I run each sql separately, I can get the correct counts, but if I try to combine them, the sql eventually times out.
Here is a sample of one of the individual sql's. There are no fields common to the tables, but the dates although named differently have the same values for what I want to select.
select (substr(to_char(order_date), 5, 2) || '/' ||
substr(to_char(order_date), 7, 2) || '/' ||
substr(to_char(order_date), 1, 4)) as "Date",
count(*) as "Order Count"
from table1 ord
where order_date between to_char(sysdate, 'yyyymmdd') and
to_char(sysdate - 3, 'yyyymmdd')
group by order_date
order by to_date(order_date, 'yyyymmdd');
Any suggestions? I'm running it via SqlPlus.
Table1: order_date, item_ordered, etc
Table2: Process_date, item_processed, etc
Table3: Shipment_date, package_count, etc
Table4: Payment_date, amount_received, etc
What I want is:
Date Order Count Processed Shipments Pmnts Rcvd
01/05 50 45 61 22
01/06 39 51 34 26
01/07 40 42 41 30
If I run each sql separately, I can get the correct counts, but if I try to combine them, the sql eventually times out.
Here is a sample of one of the individual sql's. There are no fields common to the tables, but the dates although named differently have the same values for what I want to select.
select (substr(to_char(order_date), 5, 2) || '/' ||
substr(to_char(order_date), 7, 2) || '/' ||
substr(to_char(order_date), 1, 4)) as "Date",
count(*) as "Order Count"
from table1 ord
where order_date between to_char(sysdate, 'yyyymmdd') and
to_char(sysdate - 3, 'yyyymmdd')
group by order_date
order by to_date(order_date, 'yyyymmdd');
Any suggestions? I'm running it via SqlPlus.