Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with subqueries
Message
From
20/05/2004 02:17:01
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Help with subqueries
Miscellaneous
Thread ID:
00905511
Message ID:
00905511
Views:
39
Hi to all,

I have the following structure of table A
SEM_KEY   COURSE_CODE   GENDER   STUD_YEAR
=======   ===========   ======   =========
   1         BSCS         1          1
   1         BSCS         1          2
   1         BSIT         2          1
   1         BSIT         2          2
   1         BSIT         1          3

where gender 1=Male; 2=Female
I want to obtain the following output
COURSE  1M  1F  2M  2F  3M  3F
======  ==  ==  ==  ==  ==  ==
BSCS    1   0   1   0   0   0 
BSIT    1   0   0   1   1   0

where 1M = total for male 1st year.
      1F = total for female 1st year
the output serves as a summary to view the total # of records
in each course, gender, and year.
SELE COURSE_CODE, [1M]
FROM
(SELECT COURSE_CODE, COUNT(*) AS [1M]
FROM dbo.VW_SUMMARY
WHERE (COURSE_CODE = 'BSCS') AND (STUD_YEAR = 1) AND (GENDER = 1) AND (SEM_KEY = 1)
GROUP BY COURSE_CODE, STUD_YEAR, GENDER) A
Any help will be appreciated.
Next
Reply
Map
View

Click here to load this message in the networking platform