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 |
|
martalex
Starting Member
17 Posts |
Posted - 2002-04-25 : 11:21:50
|
| Hello,I have a resume posting system. I need to generate a report on the different system activity such as how many new resumes were created, how many resumes were archived and how many resumes were approved by job category for a given time period. I have the following SQL query that do the job but not exactly how I would like. SELECT tlk_JobCategories.JC_ID, Info='RsmNewCount ', count(rsm_id) as TotalFROM tlk_JobCategories LEFT JOIN tbl_resumes ON (tlk_JobCategories.JC_Id = tbl_resumes.JC_Id) AND rsm_createdon BETWEEN { d '2002-04-01'} AND DATEADD(Day , 1, { d '2002-04-30'})GROUP BY tlk_JobCategories.JC_IdUNIONSELECT tlk_JobCategories.JC_ID, Info='RsmVisibleCount', count(DISTINCT rsm_id) as TotalFROM tlk_JobCategories LEFT JOIN tbl_historyresumes ON (tlk_JobCategories.JC_Id = tbl_historyresumes.JC_Id) AND (hrsm_statustype = 'both' AND (hrsm_enddate >= { d '2002-04-01'} OR hrsm_enddate is null) AND hrsm_startdate <= DATEADD(Day , 1, { d '2002-04-30'})) GROUP BY tlk_JobCategories.JC_IdUNIONSELECT tlk_JobCategories.JC_ID, Info='RsmArchivedCount', COUNT(DISTINCT rsm_id) as TotalFROM tlk_JobCategories LEFT JOIN tbl_historyresumes ON (tlk_JobCategories.JC_Id = tbl_historyresumes.JC_Id) AND (hrsm_statustype = 'actv' AND hrsm_enddate BETWEEN { d '2002-04-01'} AND DATEADD(Day , 1, { d '2002-04-30'})) GROUP BY tlk_JobCategories.JC_IdORDER BY tlk_JobCategories.JC_IDThe result look like the following:JC_ID Info Total ----------- ---------------- ----------- 33 RsmArchivedCount 233 RsmNewCount 233 RsmVisibleCount 634 RsmArchivedCount 034 RsmNewCount 034 RsmVisibleCount 035 RsmArchivedCount 235 RsmNewCount 235 RsmVisibleCount 036 RsmArchivedCount 336 RsmNewCount 536 RsmVisibleCount 6...I would prefer that the result look like more something like that:JC_ID RsmNewCount RsmNewCount RsmVisibleCount ----------- ----------- ----------- ---------------33 2 2 634 0 0 035 2 2 036 5 3 6Is this doable, if so, How?Thanks.--Alex |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2002-04-25 : 11:24:08
|
| search here for CSV....articles also in the FAQ on this....this is a variation on the basic problem except that your seperator is a space. |
 |
|
|
|
|
|
|
|