If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Brand New to SQL and Programing

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-18-03, 17:27
mlscw mlscw is offline
Registered User
 
Join Date: Sep 2003
Posts: 4
Question Brand New to SQL and Programing

Hi Everyone

I am learning SQL using the "Trial by Fire" method.

The program is based on Pascal and SQL. The database responds to SQL statements. This is a propriety program. The operating system is NT 4.0.

<Problem>
I need to count the number of each type of EnrolStatus for this class.


<Tables Set-Up>
Table Name: Registration
Field Names: EnrolStatus
Field Names: Class_OID

The EnrolStatus is broken down into 4 groups
0=enrolled
1=finished
2=cancelled
3=No Show

The class OID is 1300

<Tried but didn't work>

SELECT * FROM REGISTRATION WHERE REGISTRATION.CLASS_OID = 1300 AND
Recordcount(*) REGISTRATION.EnrolSTATUS = 1

I am hoping someone can help me.

Forgive me if I didn't state everything with the right terms
Reply With Quote
  #2 (permalink)  
Old 09-18-03, 23:37
shev shev is offline
Registered User
 
Join Date: Jul 2003
Location: Hong Kong
Posts: 56
Hi mlscw,

To count the number of each type of EnrolStatus of the class. You will need to use the GROUP BY clause and then take the COUNT.

select enrolstatus, count(*)
from registration
where class_oid = 1300
group by enrolstatus


HTH
__________________
Cheers,
Shev
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On