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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need some SQL programming help counting amounts

Author  Topic 

chef423
Starting Member

15 Posts

Posted - 2014-08-27 : 16:13:15
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

chef423
Starting Member

15 Posts

Posted - 2014-08-27 : 16:44:40
Total Sales for the Day, Employee Name, # of Covers
$567 Juan 22
Go to Top of Page
   

- Advertisement -