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.
| Author |
Topic |
|
jesus4u
Posting Yak Master
204 Posts |
Posted - 2003-11-05 : 10:38:54
|
| [code]select parent_table.positionname, parent_table.lastdateadded, parent_table.totals, child1.phd, child2.cert, child3.hsfrom (select dbo.positionsappliedfor.positionname, max(dbo.resumes.dateadded) as lastdateadded, count(dbo.positionsappliedfor.positionname) as totals from dbo.resumes inner join dbo.positionsappliedfor on dbo.resumes.resumeid = dbo.positionsappliedfor.resumeid where (month(dbo.resumes.dateadded) = month(getdate()) - 1) and (year(dbo.resumes.dateadded) = year(getdate())) group by dbo.positionsappliedfor.positionname, dbo.positionsappliedfor.positionname ) as parent_table left join (select dbo.positionsappliedfor.positionname, count(dbo.positionsappliedfor.positionname) as phd from dbo.resumes inner join dbo.positionsappliedfor on dbo.resumes.resumeid = dbo.positionsappliedfor.resumeid where resumes.education = 'phd' and (month(dbo.resumes.dateadded) = month(getdate()) - 1) and (year(dbo.resumes.dateadded) = year(getdate())) group by dbo.positionsappliedfor.positionname, dbo.positionsappliedfor.positionname ) as child1on parent_table.positionname = child1.positionnameleft join (select dbo.positionsappliedfor.positionname, count(dbo.positionsappliedfor.positionname) as cert from dbo.resumes inner join dbo.positionsappliedfor on dbo.resumes.resumeid = dbo.positionsappliedfor.resumeid where resumes.education = 'cert' and (month(dbo.resumes.dateadded) = month(getdate()) - 1) and (year(dbo.resumes.dateadded) = year(getdate())) group by dbo.positionsappliedfor.positionname, dbo.positionsappliedfor.positionname ) as child2on parent_table.positionname = child2.positionnameleft join (select dbo.positionsappliedfor.positionname, count(dbo.positionsappliedfor.positionname) as hs from dbo.resumes inner join dbo.positionsappliedfor on dbo.resumes.resumeid = dbo.positionsappliedfor.resumeid where resumes.education = 'hs' and (month(dbo.resumes.dateadded) = month(getdate()) - 1) and (year(dbo.resumes.dateadded) = year(getdate())) group by dbo.positionsappliedfor.positionname, dbo.positionsappliedfor.positionname ) as child3on parent_table.positionname = child3.positionnameorder by totals desc[/code]Alex Polajenko |
|
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
Posted - 2003-11-05 : 10:44:19
|
Not for the eyes |
 |
|
|
jesus4u
Posting Yak Master
204 Posts |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-11-05 : 14:08:41
|
| unless you give us some sample data, your table structures, and what you are trying to return, I don't know how anyone can tell you if it's efficient or not.- Jeff |
 |
|
|
|
|
|
|
|