Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Jptalon
Starting Member
3 Posts |
Posted - 2012-10-27 : 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 ThanksCreate 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
3 Posts |
Posted - 2012-10-27 : 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.customerJOIN 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 selectedSo 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
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-10-27 : 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
3 Posts |
Posted - 2012-10-27 : 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
52326 Posts |
Posted - 2012-10-27 : 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 MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|