Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Your site is a great idea. I should have joined your site years ago. Better late than never..."

Geography

Where in the world do Tek-Tips members come from?
ridhirao22 (Programmer)
10 May 12 15:37

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)

Thargy (TechnicalUser)
14 May 12 5:41
There's one thing that strikes me right away, and that is the NVL(COUNT.... part of the statement.
If one counts anything, the answer can never be null. The count might be zero or some other number, but it will never be null.
Thus the NVL(COUNT is pointless and may be part of the trouble.

Can you post the create table statement for the table you're selecting from, and insert statements to add a few records.
Then if you say what you're trying to obtain functionally, we can probably help more.

Regards

T

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close