Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

sql Need total time worked and total volume sold from two tables

$
0
0

Thanks in advance for any help.I have two tables, login and sales in. I need to get total time worked from the login table and total volume sold form the sales table.

SELECT L.AGENT, 

SUM (DATEDIFF(ss, LOGIN.LOGON,LOGIN.LOGOFF)/3600.0)AS TIME, 

SUM (SALES.SALEAMT) AS TOTAL 

FROM SALES JOIN LOGIN L ON L.AGENTID = SALES.AGENT 

WHERE SALES.START > '2015-09-29' GROUP BY AGENT

I expect it to return 1 column with the names of agents who worked on 9-29-15, 1 column with total hours worked on 9-29-15, and 1 column with volume sold on 9-29-2015. It is actually returning crazy high amounts for both of the summed columns.(Hundreds of hours and thousands of dollars.)


Viewing all articles
Browse latest Browse all 4871

Trending Articles