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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-12-06 : 08:29:07
|
| Kevin writes "I've got an (simplified for example purposes) employee table that contains two fields: EmployeeName and HireDate.Below is a sample dataset:EmployeeName HiredateJohn 1/1/04Tom 2/1/04Pete 3/1/04I'd like to create a query that would return list of employees by month if they worked in that month over a user supplied date range. For example, if the user wanted to query 1/1/04 - 4/30/04, they would get the following result set:Month Year Employee1 2004 John2 2004 John2 2004 Tom3 2004 John3 2004 Tom3 2004 Peter 4 2004 John4 2004 Tom4 2004 PeterI won't know in advance the date range. I could be one month, twelve months, etc. Can this be done through some kind of cross joins combined with a few extra tricks?" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
|
|
|
|
|