bjstyl2
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by bjstyl2
-
-
So here is the structure of the database...Table Employee:- Login -> (Salesperson #)- First- LastTable Salesmn- DTE -> (Daily Date)- Store- Salesman -> (Salesperson #)- Sales- SpiffsWhat I would like to get out of this is....Store - Salesperson # - Sum of Sales - Sum of Spiffs - First Name - Last Namefor a given period 1/1/2014 to 1/2/2014. Currently my method:
select salesmn.store, salesmn.salesman as employee_num, salesmn.sales, salesmn.spiffs, employee.first, employee.last from employee inner join salesmn on (employee.login = salesmn.salesman) where salesmn.dte between '1/1/2014' and '1/3/2014' order by salesmn.store, employee.last asc
My current solution provides me with the information as separate dates. I would like for them to be combined so that I could have 1 record per person with the sum of sales and spiffs. Thanks for any assistance.
HELP -> Joining 2 tables, grouping by a common value in both tables
in SQL
Posted
I can get the sum of Sales and Spiffs without the employee name, but every time I try to include the employee name I get an error that says invalid column reference.
I bet it is something small that I am missing, just can't wrap my head around it yet.