Link to home
Start Free TrialLog in
Avatar of jamppi
jamppiFlag for Sweden

asked on

sql query count failed sessions per user and 7 day period.

Hi!

I need to count the  failed sessions per CustomerName for this week or 7 day period.

Customer table.
DeviceId, Custname,,,,,,,,,,,,

session table
Sessions_Id, DeviceId, on_date_time, Off_Date_Time, Complete,,,,,,,,,,,,,

if complete is false the count it.

output should for be distinct   " custname   -  'Number of false completes""
Avatar of chaau
chaau
Flag of Australia image

This should work:
SELECT C.DeviceID, C.Custname, COUNT(*)
FROM Customer C INNER JOIN session S
ON C.DeviceID = S.DeviceID AND S.Complete = FALSE
GROUP BY C.DeviceID, C.Custname

Open in new window


I have included DeviceID in case you have two customers with the same name
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial