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
10
Other forums
problems with search form numerical "between" sending by php
I am trying to display the results of a search, on a sql database, on a web page. I set up html &quo
iMatch stored value with the current value in a loop
Hello,
I have a MySQL db were I store articles in.
I have a form to fill these article
LIMIT $start, 10... how to pass last value queried into next page with GET??
Ok I know how to display the first or last 10 results of a query...
$result = mysql_query(&q
Need to write a cookie with a url var
Not sure if its possible, but I need to write a cookie with a url.
So this would write 2232 a
how do i make new line after *
First check this page here. and you see my report. Im pulling form a mysql db. I want to beable to m
Sort a two dimensional array.
Hi. I've set up a two dimensional array that reads as follows:
Code: $modifiedData = array(
Passing JS to PHP
So I have the following
Code: <?php
getdetails(?><script type="text/
strtotime issue
Hey all,
I'm playing around with some code, and basically the idea is:
Person changes
Dealing with code in db query
I am dealing with C code and I need to make sure it is encoded some how to ensure its integrity and
How to use Ajax to verify data on a DB ?
Hello everyone, well i want to know how to check a value if it exists or not on a Data base and capt