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 2008 Forums
 Transact-SQL (2008)
 Query help

Author  Topic 

splearner
Starting Member

3 Posts

Posted - 2011-08-03 : 06:01:48
i have following three tables with columns

STAFF - EMPID, EMPNAME, DEPTID
DEPT - DEPTID, DEPTNAME
TRNG - EMPID, COURSE, STARTDATE, ENDDATE

please help me in writing the query to get the result as below

DEPTNAME, EMPNAME, COURSE, STARTDATE, ENDDATE

FOR following two conditions
1. DEPTID='123' AND EMPNAME='learner' between STARTDATE AND ENDDATE
2. DEPTID='123' AND EMPID='1144' BETWEEN STARTDATE AND ENDDATE

i appreciate your help.
Thanks & Regards
SPLEARNER

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2011-08-03 : 06:50:15
This seems like homework... but this is how you might join your tables.


...
From Staff S
Left Join Trng T On S.EmpId = T.EmpId
Left Join Dept D On S.DeptId = D.DeptId
...



Give the rest a shot... and post back what you tried if you get stuck.

Corey

I Has Returned!!
Go to Top of Page

splearner
Starting Member

3 Posts

Posted - 2011-08-03 : 20:50:23
thank you seventhnight..i got it working now with your help
Go to Top of Page
   

- Advertisement -