sql - Need help to solve query (using datepart) -
Select
- reduce the second, millisecond part of the minute, effectively round on the floor of the floor. Example '2017-03-17T14: 31: 25.567' gets '2017-03-17T14: 00: 00.000' DATEAD (mi, -1 * (DATEPART (mi, tab.lindt %% 60), DATEADD (SS, -1 * (DATEPART (ss, tab.logindt)), DATEADD (ms, -1 * (DATEPART (ms, tab.logindt)), tab.logindt))) as "date", COUNT (*) In the form the "Calculation" from the TableName tab WHERE tab.Lindt 'Date 1 2009 12:00 AM' and '2 December 2009 23:59 PM' by Group until DATEAD (miles, -1 * (DATEPART (miles, tab) .lindt)% 60, DATEADD (Ss, -1 * (DATEPART (ss, tab.logindt)), DATEADD (MS, -1 * (DATEPART (MS, tab.logindt)), Tab.Lindt))) < / Code>
We have an application in which many people are logged in, the problem is that I want to create a query through which I can get the number of people logged into the system on a system Cull time can be counted 10 am / 11/12/14
Using the datepart above the query, through which I can say 10 or the number of people signed out or sign out.
For example, the above question returns 10 people to sign / signout at 10 o'clock, but it does not show me those people who are currently using the system. Search all log in / logout events before 10am and select those maximum (login)> maximum (logout)
SELECT COUNT * (SELECT * FROM table WHERE login <10:00 // your date function here and logout & lt; 10am) by a group a.USER HAVING MAX ( A.login) & gt; MAX (a.logout)
Something like this?
Comments
Post a Comment