Need help with basic sql


Posted on 16th Feb 2014 07:03 pm by admin

Hi,

I am using oracle 10g, and having some small doubts related to sql , here goes the situation

I have a Transaction table , which contains records/transaction carried out by a employee under a Reason code on various dates, refer to below sample data

EMP_CODE REASON_CODE DATE

A001 B1 1st Jan 2009
A001 B1 3rd Jan 2009
A001 B1 6rd Jan 2009
A001 C2 9th Jan 2009

A002 D4 1st Jan 2009
A002 D4 3rd Jan 2009
A002 D5 6rd Jan 2009

A003 E6 6rd Jan 2009
A003 E6 7rd Jan 2009
Effectively i want to have final result as follows (i.e. some how hide A003 , refer to below for reason )

A001 B1
A001 C2
A002 D4
A002 D5
*So basically print Employee code and reason code only if employee has done transaction under more than 1 reason code, since employee code 'A003' carried out transaction ONLY under 1 UNIQUE Reason code , i dont want his record to be printed.*

the current query which i wrote is as follows :

select emp_cd, reas_cd
from employee_trans_table
where reas_cd ' '
group by emp_cd, reas_cd
order by emp_cd, reas_cd

but this prints results as

A001 B1
A001 C2
A002 D4
A002 D5
A003 E6

How do i avoid prnting A003/E6 since it had only 1 reason code attached to it..
I hope i am able to clearly state the doubt which i have, let me know if you require any further info/clarrification on this.

No comments posted yet

Your Answer:

Login to answer
193 Like 10 Dislike
Previous forums Next forums
Other forums

Unable to customise toolbar in FCK
Help with forum quoting?
Hi im working on a forum and I have alomost finished it but i want a user quote system like twitter

Login script (probably a simple error)
dbConfig.php
Code: <?
// Replace the variable values below
// with your specific dat

Perplexing problem showing a .jpg
Please disregard..........I figured it out

Error in write byte array into document in SM58
Hi Gurus,

Getting the following error status in Transactional RFC (SM58) ..... *Error i

login box shows up again after logging in 2nd login works
Hello,

I am having trouble on my site Lockerz.rack111.com where when you login the login box

Checking BOM Authorization Group
Hai Friends,

I have developed a mulitilevel BOM display report. End users have been assig

Problems with strings containing
Hey all,

I have encountered something strange in a script. I am trying to write an XML heade

temporary objects
Until now i thought every temporary object in C++ is created as constant. I'm wondering why my compi

Where do I put CRON code
So I've figured out alot about how to automatically run a php function. I can't figure out where to

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash