| Author |
Topic  |
|
|
Jptalon
Starting Member
USA
3 Posts |
Posted - 10/27/2012 : 13:19:24
|
Hello all, New here and yes this is classwork. No I'm not looking for just the answer lol. I need to understand this, not just pass the class. Anyways, here is the ERD Im using, and just below it is the output I need. I can do each on its own but not together. Im sure I need the Group by, just haven't gotten it to work. I'm taking classes online and have emailed for help with no response, hence coming here. Any help appreciated Thanks
 Create a customer report that lists all customer's names, the number of charters they have booked, and the total cost of all charters. Remember to include all customers, even customer’s that currently do not have any charters booked. |
|
|
Jptalon
Starting Member
USA
3 Posts |
Posted - 10/27/2012 : 14:19:36
|
SELECT TRIM(customer.cus_fname) || DECODE(customer.cus_initial,NULL, ' ', ' ' || customer.cus_initial || '. ') || TRIM(customer.cus_lname) "Customer Name", COUNT(charter.char_trip) "# of Flights" FROM xxx.customer JOIN xxx.charter ON customer.cus_code = charter.cus_code GROUP BY customer.cus_fname, customer.cus_initial, customer.cus_lname;
OUTPUTS this....
Customer Name # of Flights -------------------------------------------- ------------ James G. Brown 3 George Williams 4 Olette K. Smith 1 Kathy W. Smith 2 Leona K. Dunne 4 Alfred A. Ramas 1 Myron Orlando 3
7 rows selected
So I got this part to work right after posting, but it does not list all customers. How could I add that? NULL I believe is what I want.... |
 |
|
|
sunitabeck
Flowing Fount of Yak Knowledge
5152 Posts |
Posted - 10/27/2012 : 14:29:57
|
Use LEFT OUTER JOIN instead of INNER JOIN.
BTW, this forum is a Microsoft SQL Server forum, so expertise on other DBMSs are likely to be far and few in between. You will get better and faster responses for other DBMSs at a forum such as dbforums.com |
 |
|
|
Jptalon
Starting Member
USA
3 Posts |
Posted - 10/27/2012 : 14:36:18
|
| Thanks. I was just looking back on OUTER JOINS. I will also check the other forum out as I am using SQL developer |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47069 Posts |
Posted - 10/27/2012 : 21:19:03
|
quote: Originally posted by Jptalon
Thanks. I was just looking back on OUTER JOINS. I will also check the other forum out as I am using SQL developer
the code looks more like Oracle to me
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
| |
Topic  |
|