Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old March 29th, 2004, 10:11 PM
tjtee tjtee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 101 tjtee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Cool how do I count this?

I have three tables:

BS_REGISTRATION
-----------------
REG_ID (PK)
REG_ATTEND
SESSION_ID (FK)

BS_SESSION
------------
SESSION_ID (PK)
SESSION_DATE
COURSE_ID (FK)

BS_COURSE
-----------
COURSE_ID (PK)
COURSE_NAME

I would like to find out the count of registration sorted by course. e.g.

COURSE1 34
COURSE2 12

SELECT c.COURSE_NAME, count(REG_ID) from BS_SESSION s, BS_REGISTRATION r, BS_COURSE c
WHERE s.SESSION_ID = r.SESSION_ID
AND s.COURSE_ID = c.COURSE_ID
AND TO_DATE(s.SESSION_DATE) BETWEEN TO_DATE('12-03-2003','DD-MM-YYYY') AND TO_DATE('31-03-2004','DD-MM-YYYY')
AND r.REG_ATTEND='attended'
GROUP BY COURSE_NAME

I know if I do the above I will get an error. But how do I do this query? Thank you so much.

Reply With Quote
  #2  
Old March 30th, 2004, 02:16 AM
shammat shammat is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 972 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 50 m 23 sec
Reputation Power: 57
You did not write what the error message is, that you get, but if SESSION_DATE is already defined as a date column you don't need the TO_DATE(s.SESSION_DATE) (and I guess it will give an error)

I think

AND s.SESSION_DATE BETWEEN TO_DATE('12-03-2003','DD-MM-YYYY') AND TO_DATE('31-03-2004','DD-MM-YYYY')

should work (didn't test it though)

Reply With Quote
  #3  
Old March 31st, 2004, 01:52 PM
jimbag8 jimbag8 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 28 jimbag8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
just as a side note...the left side "to_date" function will also hurt your performance. If the field is a date field already I would definatley take that out.

~jimbag8

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > how do I count this?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway