sql query like this i need

Posted by Jayakumars under Regular Expressions on 7/14/2011 | Points: 10 | Views : 1226 | Status : [Member] [MVP] | Replies : 3
hi

my table data like this
emphead-tablename
====================
empid ename
1 Jayakumar
2 David
3 Kutty

empdet-tablename
===================
id empid name amt
1 1 Jayakumar 4500
2 1 Jayakumar 9500
3 3 kutty 2500

i need output like this only
1 1 jayakumar 9500
3 3 kutty 2500

Mark as Answer if its helpful to you


Responses

Posted by: Jpchoudhari on: 7/14/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

You can do this by simply joining two tables.
http://www.w3schools.com/sql/sql_join.asp

This is very basic;



Kind Regards,
Jay

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A4u_6178 on: 7/14/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Jayakumrs,
These queries below address ur requirement to some extent, if u get the solution let me know
select det.id, e.empid, det.empname, det.salary from emp as e inner join empdet det on e.empid=det.emp_id where (det.id=2 or det.emp_id=3)


and
select det.id, e.empid, det.empname, det.salary from emp as e inner join empdet det on e.empid=det.emp_id where (det.id<>2 or det.emp_id=3)



Thanks & Regards,

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Umeshdwivedi on: 7/14/2011 [Member] Starter | Points: 25

Up
0
Down
hallo try this
SELECT empid,name, MAX(amt) as "Highest salary"
FROM employees
GROUP BY empid;

Latest Technology Trainer
And Part time software consultant

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response