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

Email logic not working
I would like to send an email using the php email() function then if it does execute i.e sends i wou

"GROUP BY" in arrays
Well i'm looking to do something i usually could do easily using COUNT and GROUP BY if it was a sql

Text file to .Dat file Conversion in PHP
Hi All,
Could anybody provide code for Text file to .Dat file Conversion in PHP.

Tha

Agency Business Process
Hi,

I don’t understand the process of the agency business in SAP.

In my

Troubles with a spider class
I am building a spider that will crawl through random whitepages (eg. anywho.com, switchboard.com, w

array & querys help/advice.
Ok so here goes , I have a mysql database and basically here's what I need to do.

// foreach

Multi Level Array Problem
hi all,

For example I have array like below:

$temp = array(array('north america', 'us'

problem with php server update from mid 2009
Hi,

I have this navigation menu on 2 websites which used to work just fine. After a recent up

images aren't rendering
I'm trying to call a JPG file from within PHP (in an effort to hide the actual JPG folder). The imag

Why do I get this error
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/a5488351/public_html/b

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