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
10
Other forums
get the country of visitor and display content based on that
Hello all,
I have seen that Google analytics can tell you where a visitor is coming from and
Prevention Help
How can I use PHP or any other language (feel free to move this thread) to prevent users doing scree
present value of sequence?
Hi
Please help me to find out the present value of sequence?
Thanks
Image loading
Hi Developers,
I'm trying to display an image from images/image.gif getting the url from mysq
a dificult string search
Hi I don't know a way around this. I want the user to input a password, but to make it a bit complca
Extending Exception to contain method name
I was wondering, if there's a way to extend Exception in such a way, that it would contain name of a
Populate drop down list from table??
Lets say for arguments sake that i have a table which contains the numbers 1 to 10.
How can i get
this code is not working????
it says this error.. Warning: Division by zero in ..
the variables are correct, so why is th
Count
Getting the same count everytime
Code:
$visitquery = mysql_query("SELECT COUNT(*) FR
Where am I going wrong
Been trying to work this out for hours
I have two tables called 'Genres' and 'Films'. Genre