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 |
rba88usa
Starting Member
1 Post |
Posted - 2011-02-15 : 14:09:13
|
I have wrote a SQL script using union 12 times, one for each month, but my supervisor said I can do that in one shot using Group by Month. I tried several examples but they do not work. Here is what I am trying to do if you could help will be great.I am trying to Count the students with those particular qualities out of my DB. SELECT COUNT (*) AS COUNTER, MONTH(A.ADM_APPL_DT) AS 'Month' FROM PS_ADM_APPL_DATA A, PS_ACAD_PROG C WHERE A.INSTITUTION = 'NV280' AND A.LAST_SCH_ATTEND IN ('5653934','5653933') AND A.ADM_APPL_DT BETWEEN TO_DATE('2010-01-01','YYYY-MM-DD') AND TO_DATE('2010-12-31','YYYY-MM-DD') AND C.EFFDT = (SELECT MAX(C_ED.EFFDT) FROM PS_ACAD_PROG C_ED WHERE C.EMPLID = C_ED.EMPLID AND C.ACAD_CAREER = C_ED.ACAD_CAREER AND C.STDNT_CAR_NBR = C_ED.STDNT_CAR_NBR AND C_ED.EFFDT <= SYSDATE) AND C.EFFSEQ = (SELECT MIN(E_ES.EFFSEQ) FROM PS_ACAD_PROG E_ES WHERE C.EMPLID = E_ES.EMPLID AND C.ACAD_CAREER = E_ES.ACAD_CAREER AND C.STDNT_CAR_NBR = E_ES.STDNT_CAR_NBR AND C.EFFDT = E_ES.EFFDT) AND C.EMPLID = A.EMPLID AND C.ACAD_CAREER = A.ACAD_CAREER AND C.STDNT_CAR_NBR = A.STDNT_CAR_NBR AND C.ADM_APPL_NBR = A.ADM_APPL_NBR AND C.CAMPUS <> 'L' GROUP BY MONTH(A.ADM_APPL_DT) |
|
MIK_2008
Master Smack Fu Yak Hacker
1054 Posts |
Posted - 2011-02-15 : 15:11:19
|
come up an examples of the table, few rows for them and the desired output format as per example. This will help us to help you !!! |
|
|
|
|
|