Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Reg Query

Author  Topic 

vmurali
Yak Posting Veteran

88 Posts

Posted - 2006-08-20 : 11:32:35
Hi,
I have basically 3 tables employee, employeepromo and employeetrans I have to get
1. Number of employees who have been transfered with a promotion
2. Empname,dept,level,latest desig, latest dt_of_promo,number of transfers

Table Columns
-------- ----------
Emp empid, name,dept,level
Emptrans transid,empid,tobranch,dt_of_trans
emppromo promoid,empid,desig,dt_of_promo

panthagani
Yak Posting Veteran

58 Posts

Posted - 2006-08-20 : 16:33:07
For your first question, try this and see if it works...

select empid,name from EMP E1 INNER JOIN EMPTRANS E2
on E1.empid = E2.empid INNER JOIN EMPPROMO E3
on E1.empid = E3.empid
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-08-20 : 20:48:13
Homework?

CODO ERGO SUM
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-21 : 00:34:34
Learn SQL

http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

vmurali
Yak Posting Veteran

88 Posts

Posted - 2006-08-21 : 02:37:50
Is this correct

select emp.name,emp.edept,emp.elevel, (emppromo.desig) as Ldesig , (emppromo.dt_of_promo) as Ldate, count(emptransfer.transid) as mCount from emp
left outer join emptransfer on emp.empid=emptransfer.empid
left outer join emppromo on emppromo.empid=emp.empid
group by emppromo.desig ,emppromo.dt_of_promo, emp.name,emp.edept,emp.elevel

order by count(emptransfer.transid) desc
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-21 : 05:05:23
Run that and see the result

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -