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 > PC based Database Applications > Microsoft Access > Show records based on value

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-24-12, 14:48
adrianc adrianc is offline
Registered User
 
Join Date: Apr 2012
Posts: 3
Show records based on value

Hi everyone,

I'm going to get straight to it. Basically, what I need to do is show records based on another field.

The scenario:

I have a list of employees, the employees have attended many courses (there are different courses). The employees have either passed or failed the course. I need to create a report that shows only those that have failed 3 or more courses. The calculation has to be based on a yes/no field. I am guessing that a query has to be made, however I don't know how to go about it .

Any ideas?
Reply With Quote
  #2 (permalink)  
Old 04-24-12, 15:23
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 20,000
start by showing us a query that retrieves all students and all their courses
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 04-24-12, 15:26
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,360
Query to show number of fails for each person [that has failed a test]
Code:
SELECT person
     , Count(*)
FROM   courses
WHERE  pass = 0
GROUP
    BY person
To limit this query to show only those who have 3 or more failures add this to the end
Code:
HAVING Count(*) >= 3
__________________
George
Home | Blog
Reply With Quote
  #4 (permalink)  
Old 04-24-12, 16:30
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 20,000
george, come on, you have to make it just a ~wee~ bit harder for these n00bs to get their homework assignments completed
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 04-24-12, 17:35
adrianc adrianc is offline
Registered User
 
Join Date: Apr 2012
Posts: 3
This works, thank-you, however for the last part, I get the error 'Characters found after end of statement.

Thanks again


Quote:
Originally Posted by gvee View Post
Query to show number of fails for each person [that has failed a test]
Code:
SELECT person
     , Count(*)
FROM   courses
WHERE  pass = 0
GROUP
    BY person
To limit this query to show only those who have 3 or more failures add this to the end
Code:
HAVING Count(*) >= 3
Reply With Quote
  #6 (permalink)  
Old 04-24-12, 17:58
adrianc adrianc is offline
Registered User
 
Join Date: Apr 2012
Posts: 3
Thank youuuuu

No worries, found that I forgot to remove the ';'

Thank you soo much
Reply With Quote
Reply

Tags
count, iif

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