Notices
The Basement Non-Honda/Acura discussion. Content should be tasteful and "primetime" safe.

SQL question (not as difficult as the others)

Thread Tools
 
Old Oct 23, 2007 | 10:39 AM
  #1  
Pete's Avatar
Pete
Thread Starter
Civilian
 
Joined: Jun 2003
Posts: 8,407
Likes: 1
From: Miami Beach. FL
Default SQL question (not as difficult as the others)

Trying to create a list of customers and how many charters each has booked:

Code:
SELECT (c.cus_fname ||' '|| c.cus_lname) Customer, COUNT(ch.char_date) as "Num of Booked Charters"
FROM hartmar.customer c JOIN hartmar.charter ch ON c.cus_code = c.cus_code
GROUP BY Customer
;
I get this error:

ERROR at line 3:
ORA-00904: "CUSTOMER": invalid identifier
Any ideas?
Reply
Old Oct 23, 2007 | 11:34 AM
  #2  
Pete's Avatar
Pete
Thread Starter
Civilian
 
Joined: Jun 2003
Posts: 8,407
Likes: 1
From: Miami Beach. FL
Default

Nevermind, I got it:

Code:
SELECT (c.cus_fname || ' ' || c.cus_lname) Customer,
       COUNT(ch.char_trip) as "Number of Charters"
FROM hartmar.customer c JOIN hartmar.charter ch ON c.cus_code = ch.cus_code
GROUP BY c.cus_fname, c.cus_lname 
;
Reply




All times are GMT -8. The time now is 02:33 AM.