Click to See Complete Forum and Search --> : SQL Query help


monkeymafia
March 21st, 2007, 09:23 AM
Hi having a little trouble with a sql query. am trying to find the total number of passengers on each cruise. any helpers or pointers would be greatly appreciated.
i have a customer booking table which is made up of 2 foreign keys: customer ID and voyage ID

if i do:


select count (distinct voyage_ID) from booking


it obviously gives me the number of different voyages. but how would i calculate the number of customers on each of these voyages?

I am using Oracle

RhinoBull
March 21st, 2007, 03:19 PM
You can try this:

SELECT voyage_ID, COUNT(customer_id) TotalCount
FROM booking
GROUP BY voyage_ID
ORDER BY voyage_ID

monkeymafia
March 25th, 2007, 01:10 PM
thanks for this!