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

Did you know?Explore Trending and Topic pages for more stories like this.
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

a function to check directory depth
I'm working on a php script to upload files in to a set directory.
the user can select to upload

PHP Mysql Staff Induction System
Hi there, I'm pretty new to PHP and Mysql so could really do with being pointed in the right directi

weeks in a year
hi,

i found this snippet on php.net
QuoteFor the week number for weeks starting on Sunday:

Retrieving innerHTML with cURL?
Hey all (sorry I know I'm a leecher, but I soon won't be. This is my first PHP project, but not my l

upload image name with extension using php
hi frds..

<input id="file1" type="file" name="file[]" &a

Request.UrlReferrer
I need to make it so that a page can only be loaded when a button is clicked on a specific page. I d

Can I call a class inside a function?
I have a class written in another file that handles my image resizing.

Can I do this (php say

Generate PDF
Hi guys,

I would like to know if there is a way to generate pdf when clicking on a link. In f

Multipe Dynamic Controls & AutoPostback Issue
I currently have a need to create many dynamic controls (Example Textboxes) that need to do a PostBa

Shuffle between users ??
I have multiple $users in table. I need to send them $message.

I need to send the next messag

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