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
 Need some SQL programming help counting amounts
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

15 Posts

Posted - 08/27/2014 :  16:13:15  Show Profile  Reply with Quote
Hi everyone, I need some basic SQL programming help.

I have a data set that is for a restaurant. We need to find the total amount in sales (c_items_total) for each unique user plus the number of covers (patrons) for the same day.

The table is below. I know how to use the SUM() function but I don't know how to add up all the sales for each User (employee) per day, and then also total the covers (patrons) for that day as well.

So, Total_Sales, Employee, # of Covers (for a given day)

Such as, User#1 has 10 tables for the day plus 30 people total he served.

Thanks in advance!!!

select t.c_items_total, t.i_user_id, t.i_void_ticket_id, e.s_name, t.cover_count
FROM Ticket AS t
INNER JOIN Employees AS e
ON t.i_user_id = e.i_employee_id
WHERE t.i_void_ticket_id > 0
GROUP BY t.c_items_total, t.i_user_id, t.i_void_ticket_id, e.s_name, t.dt_create_time, t.dt_close_time, t.cover_count

Starting Member

15 Posts

Posted - 08/27/2014 :  16:44:40  Show Profile  Reply with Quote
Total Sales for the Day, Employee Name, # of Covers
$567 Juan 22
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.05 seconds. Powered By: Snitz Forums 2000