I have looked up as much as I can, but my head is ready to explode.
I have output like this:
PHP Code:
CUST DETAIL INTERVAL
Bender .98 Breakdown 8/5/2003 4:00:00 PM
Diblasi 0 8/5/2003 4:00:00 PM
Bender 0 8/5/2003 4:15:00 PM
Diblasi 0 8/5/2003 4:15:00 PM
Bender 0 8/5/2003 4:30:00 PM
Diblasi 0 8/5/2003 4:30:00 PM
Bender 0 8/5/2003 4:45:00 PM
Diblasi 0 8/5/2003 4:45:00 PM
I would like to pivot the Interval so it groups and goes to the top
and then group the customers with their data going across.
Example:
PHP Code:
CUST 8/5/2003 4:00:00 PM 8/5/2003 4:15:00 PM
Bender .98 Breakdown 0
Diblasi 0 0
You get the idea, but I am at a loss how to do it.
I have the following query which gets the output I supplied above:
Code:
SELECT
c.lname_txt||' '||ci.eim_serial_id AS CUSTOMER,
SUM(ci.on_pct_nbr) / 100||' '||
(CASE
WHEN p.end_dt > ci.end_dt AND SUM(ci.on_pct_nbr) > 0 THEN 'Breakdown'
WHEN p.override_dt > ci.end_dt AND SUM(ci.on_pct_nbr) > 0 THEN 'Breakdown'
WHEN p.override_dt < ci.end_dt AND SUM(ci.on_pct_nbr) > 0 THEN 'Override'
WHEN p.end_dt < ci.end_dt THEN 'Completed' END) AS USAGE,
MIN(ci.end_dt-(4/24)) AS INTERVAL
FROM
dr_evt_participant p,
gateway_premise gp,
eim e,
compressor_interval ci,
customer c
WHERE
p.org_id = 'ME' AND
p.event_id = '03080500' AND
p.conflict_ind IS NULL AND
p.start_dt IS NOT NULL AND
gp.org_id = p.org_id AND
gp.cust_id = p.cust_id AND
e.org_id = gp.org_id AND
e.gateway_id = gp.gateway_id AND
ci.org_id = e.org_id AND
ci.eim_serial_id = e.eim_serial_id AND
ci.end_dt >= TO_DATE('080503 2000', 'MMDDYY HH24MI') AND
ci.end_dt <= TO_DATE('080603 0015', 'MMDDYY HH24MI') AND
gp.org_id = c.org_id AND
gp.cust_id = c.cust_id
GROUP BY
ci.eim_serial_id,p.end_dt,
c.lname_txt,
p.OVERRIDE_DT,
ci.end_dt
ORDER BY
ci.end_dt, c.lname_txt ASC;
thanks in advance.