473,385 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Count Problem Urgent

3
Hi

I have a table named StudentResult









UserID School Semester Grade Campus Status

1 School1 Summer 10 Campus1 Accepted
2 School1 Summer 10 Campus1 Accepted
3 School1 Summer 10 Campus1 Rejected
4 School1 Summer 10 Campus1 Rejected
5 School1 FALL 10 Campus1 Accepted
6 School1 Summer 12 Campus1 Accepted
7 School1 Summer 12 Campus1 Rejected
8 School1 Summer 12 Campus1 Accepted
9 School1 Summer 12 Campus1 Rejected
10 School1 Summer 12 Campus1 Accepted
11 School1 FALL 12 Campus1 Rejected
12 School1 FALL 12 Campus1 Accepted
13 School1 FALL 11 Campus1 Rejected
14 School1 FALL 11 Campus1 Accepted
15 School1 FALL 11 Campus1 Accepted
16 School1 Summer 11 Campus1 Rejected
17 School1 Summer 11 Campus1 Accepted
18 School1 Summer 11 Campus1 Accepted


I want to take the number of accepted and rejected users from the above table as the result table below.I want to consider grade,Campus and semester for taking count and the result should be like result table.Please help me to write Query for this.
I am using SQL server2000. as database


School Semester Grade Campus NoofAccepted NoofRejected

School1 Summer [left] 10 Campus1 2 2
School1 Fall 10 Campus1 1 0
School1 Summer 11 Campus1 2 1
School1 Fall 11 Campus1 2 1
School1 Summer 12 Campus1 3 2
School1 Fall 12 Campus1 1 1

Thanx
Oct 25 '07 #1
1 805
sayedul
12
Hi

I have a table named StudentResult









UserID School Semester Grade Campus Status

1 School1 Summer 10 Campus1 Accepted
2 School1 Summer 10 Campus1 Accepted
3 School1 Summer 10 Campus1 Rejected
4 School1 Summer 10 Campus1 Rejected
5 School1 FALL 10 Campus1 Accepted
6 School1 Summer 12 Campus1 Accepted
7 School1 Summer 12 Campus1 Rejected
8 School1 Summer 12 Campus1 Accepted
9 School1 Summer 12 Campus1 Rejected
10 School1 Summer 12 Campus1 Accepted
11 School1 FALL 12 Campus1 Rejected
12 School1 FALL 12 Campus1 Accepted
13 School1 FALL 11 Campus1 Rejected
14 School1 FALL 11 Campus1 Accepted
15 School1 FALL 11 Campus1 Accepted
16 School1 Summer 11 Campus1 Rejected
17 School1 Summer 11 Campus1 Accepted
18 School1 Summer 11 Campus1 Accepted


I want to take the number of accepted and rejected users from the above table as the result table below.I want to consider grade,Campus and semester for taking count and the result should be like result table.Please help me to write Query for this.
I am using SQL server2000. as database


School Semester Grade Campus NoofAccepted NoofRejected

School1 Summer [left] 10 Campus1 2 2
School1 Fall 10 Campus1 1 0
School1 Summer 11 Campus1 2 1
School1 Fall 11 Campus1 2 1
School1 Summer 12 Campus1 3 2
School1 Fall 12 Campus1 1 1

Thanx
Hi,

Try the sql below:

select School, Semester, Grade, Campus, NoofAccepted = sum(case Status when 'Accepted' then 1 else 0 end),
NoofRejected = sum(case Status when 'Rejected' then 1 else 0 end)
from StudentResult
group by School, Semester, Grade, Campus

I have not tested it. Hope it will work.
Oct 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Sébastien Ros | last post by:
During the process of an XML document, I have to make a SelectNodes() call on an XmlDocument. It returns an isntance of XPathNodeList. I can call it several times but at one point, the result can't...
3
by: junaidnaseer | last post by:
Is it possible to actually count the number of addition or multiplication operations performed in a program during runtime . I know of a program that does this simply by looking through the code...
3
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the packet has the urgent flag set, the text read from...
1
by: questionit | last post by:
Hi This is duplicate post due to no answert.. its a bit urgent Me.Form.RecordSource = strSQL How can i get the record count by using above statement. I am interested in getting '0'...
2
by: nish85 | last post by:
Hi I have a table named StudentResult
7
by: AccessHunter | last post by:
Hi, Please help with this problem. I have a report that displays a list of Case/Judge Records. using the following fields, Case Nbr, Case Seq Nbr, Judge Name, Attorney name 723187, 1...
0
by: imran haq | last post by:
Hi All, I have 3 rather Long Questions that are causing alot of trouble: I would appreciate all the help i can get and tried to use A post sent to atli in the past but it did not help... !) I...
4
by: AccessHunter | last post by:
Hi, I have a table with the type of data as below, sorted as follows, Case (ascending), Loc (ascending) and Transaction Date (ascending). CASE LOC TRANSACTION DATE FACILITY...
1
by: padmaneha | last post by:
Count should be displayed as zero if there is are no recipes posted select f.dishes,f.contentid,f.titleurl,count(f.dishes) as Recipescount from food f inner join foodmemberpref fmp on...
9
by: smarttechie | last post by:
Hii all please help its urgent i have developed an application in xsl. what i want to do is i m searching the xml file based on a search.and based on that search im creating one tree like...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.