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 > Database Server Software > MySQL > challenging query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-20-10, 06:18
maskme maskme is offline
Registered User
 
Join Date: Jan 2010
Posts: 1
Angry challenging query

Dear All

I've a table which stores values of people attending sports class in different locations in 7 days

For e.g.

Record ID | Location | Day
---------------------------------
1 | LA | Day 1
1 | LA | Day 2
1 | LA | Day 3
2 | BA | Day 1
2 | BA | Day 4
2 | BA | Day 7


The above is just a sample I've records of 30,000 where people attend every day till Day 7 and some only attend Day 1 or Day

3 etc...

Now I want the following results

The first question would be how many people attended every day? - I got this One (means all Day 1, Day 2, Day 3, Day 4,

Day 5, Day 6, Day 7)

second how many missed a day or more?
(not able to get this one)

third how many people attended for less than 3 days (can be any either Day 1, Day 2, Day 3, Day 4, Day 5, Day 6, Day 7)?
(not able to get this one)

fourth how many people attended only on Day 7?
(not able to get this one)

Any help would be really great!!!!!!!!

Thanks a lot.
Reply With Quote
  #2 (permalink)  
Old 01-20-10, 06:36
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,407
Quote:
Originally Posted by maskme View Post
Any help would be really great!!!!!!!!
Show us what you have so far and we'll be happy to correct/optimize your statements.

Don't forget to include the error messages (copy & paste them) if you have syntax problems.
If you are not getting the result you want, show us what the result is and point out the missing/wrong information.

You will also get a lot more answers if you post the necessary CREATE TABLE statements and ideally some INSERT statements to populate the tables with sample data.
Reply With Quote
  #3 (permalink)  
Old 01-20-10, 07:09
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
It might also be worth pointing out that it's homework.
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