sql - How can I get the min and max date per date of employees? -


this table looked like:

employee_number       |       datetime 00000001              |       2014/01/14  09:20 00000001              |       2014/01/14  12:35 00000001              |       2014/01/14  13:35 00000002              |       2014/01/14  09:20 00000001              |       2014/01/14  22:49 00000001              |       2014/01/15  09:35 00000001              |       2014/01/15  10:35 00000001              |       2014/01/15  17:35 00000002              |       2014/01/14  12:34 00000002              |       2014/01/14  17:34 

i want select statement min , max datetime of employee per day this:

employee_number       |       datetime             min                  max 00000001              |       2014/01/14      2014/01/14  09:20    2014/01/14 22:49 00000001              |       2014/01/15      2014/01/15  09:35    2014/01/15 17:35 00000002              |       2014/01/14      2014/01/14  09:20    2014/01/14  17:34 

i searched google find answer dilemma near sql statement can have this:

declare @tmp table ( trandate int, trantime datetime                     )   insert @tmp  select convert(int, convert(nvarchar(100), datetime,112)) ,datetime tblextract   select trandate, min(trantime) 'min' , max(trantime) 'max' @tmp  group trandate 

the problem shows min , max of day not per employee_number. how can solve this?

first of all, must add employee_number tmp table.

next, in last statement, must write

group trandate, employee_number 

the reason minimum corresponding each trandate , employee_number pair, required.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -