Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Simple query help
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

3 Posts

Posted - 10/27/2012 :  13:19:24  Show Profile  Reply with Quote
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.

Starting Member

3 Posts

Posted - 10/27/2012 :  14:19:36  Show Profile  Reply with Quote
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....
Go to Top of Page

Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/27/2012 :  14:29:57  Show Profile  Reply with Quote

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
Go to Top of Page

Starting Member

3 Posts

Posted - 10/27/2012 :  14:36:18  Show Profile  Reply with Quote
Thanks. I was just looking back on OUTER JOINS. I will also check the other forum out as I am using SQL developer
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 10/27/2012 :  21:19:03  Show Profile  Reply with 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

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.04 seconds. Powered By: Snitz Forums 2000