ridhirao22
Programmer
Hi, I have been struggling to get this code work for me and don't know what is wrong. I keep getting this error ORA-03113: End-of-file on communication. This is causing by using the distinct in the count. I remove the distinct it works but the data is wrong. Thanks in advance! RR
Using Oracle 11g
SELECT TRUNC (oh.orderdate) Orderdate,
DECODE ( (p.brand), 'FACTORY', 'F', 'R') brand,
(CASE WHEN (OH.COUNTRY IS NULL) THEN (A.COUNTRY) ELSE OH.COUNTRY END)
COUNTRY,
NVL (
COUNT (
DISTINCT (CASE
WHEN OH.PROMOTIONCODE NOT IN
(SELECT TO_CHAR (EMPLOYEE_ID) FROM EMPLOYEE)
THEN
ordernum
END)),
0)
PROMO_ORDERS
FROM ORDER_HEADERS OH,
ORDER_LINES OL,
PRODUCTS P,
ADDRESS A
WHERE OH.ORD_ID = OL.ORD_ID
AND OH.ADD_ID = A.ADD_ID
AND OL.PRD_ID = P.PRD_ID
AND OH.ORDERDATE >= TRUNC (SYSDATE) - 1
AND Ol.ORDERlineDATE >= TRUNC (SYSDATE) - 1
GROUP BY TRUNC (oh.orderdate),
DECODE ( (p.brand), 'FACTORY', 'F', 'R'),
(CASE WHEN (OH.COUNTRY IS NULL) THEN (A.COUNTRY) ELSE OH.COUNTRY END)
Using Oracle 11g
SELECT TRUNC (oh.orderdate) Orderdate,
DECODE ( (p.brand), 'FACTORY', 'F', 'R') brand,
(CASE WHEN (OH.COUNTRY IS NULL) THEN (A.COUNTRY) ELSE OH.COUNTRY END)
COUNTRY,
NVL (
COUNT (
DISTINCT (CASE
WHEN OH.PROMOTIONCODE NOT IN
(SELECT TO_CHAR (EMPLOYEE_ID) FROM EMPLOYEE)
THEN
ordernum
END)),
0)
PROMO_ORDERS
FROM ORDER_HEADERS OH,
ORDER_LINES OL,
PRODUCTS P,
ADDRESS A
WHERE OH.ORD_ID = OL.ORD_ID
AND OH.ADD_ID = A.ADD_ID
AND OL.PRD_ID = P.PRD_ID
AND OH.ORDERDATE >= TRUNC (SYSDATE) - 1
AND Ol.ORDERlineDATE >= TRUNC (SYSDATE) - 1
GROUP BY TRUNC (oh.orderdate),
DECODE ( (p.brand), 'FACTORY', 'F', 'R'),
(CASE WHEN (OH.COUNTRY IS NULL) THEN (A.COUNTRY) ELSE OH.COUNTRY END)