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

Displaying image pathname instead of image
Hello

Im trying to upload and then display images from a mysql database - Its only basic and

user administration
Dear @all,

what I have to do to set the user defaults for new users. At the moment I woul

Sending an SMS Message with ASP.NET
Often times it may be a requirement for your web application to send an SMS message. Such examples w

Word filter problem
Hello,

im trying to make a filter for words inputted in to my website but i want to store the

Adding to the next element in a multidimensional array
Hi, I'm trying to add a value to $node->field_spaces['nid'] where x is the next available spo

how do i display data on a page from mysql
1 - do i use this code at the top of each of my page i wish to only alow access if there as been a s

Recording popularity by day, week.. all time?
Hey everyone, I'm creating a site designed around users uploading music. How can I implement a syste

How to show the difference between two data field in a database with php.
Hello php gurus,

how r u all... i'm not so well facing a typical problem please help me...<

update post issues
I am trying to create an update to a post function, while the update does occur, the page routing an

Displaying image from database
Hi,

I've got a site where that's got a database behind it. Currently it has loads of items in

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