sql server - select SQL statement -
sorry i'm new sql server world
this checktime table
select * checkinout userid= 467 , checktime>'2014-10-24 00:00:00:000' order checktime useid checktime 467 2014-10-24 02:18:20.000 467 2014-10-24 17:04:43.000 467 2014-10-25 02:31:40.000 467 2014-10-25 17:13:38.000 467 2014-10-25 20:59:10.000 467 2014-10-27 17:22:06.000 467 2014-10-28 02:55:57.000 467 2014-10-28 17:57:12.000 467 2014-10-29 02:36:30.000 467 2014-10-29 17:13:35.000 467 2014-10-30 02:35:47.000 467 2014-10-30 17:17:56.000 467 2014-10-31 03:02:50.000 467 2014-10-31 17:19:18.000 467 2014-11-01 02:42:18.000 467 2014-11-01 17:16:14.000 467 2014-11-02 02:44:00.000 467 2014-11-03 17:20:10.000 467 2014-11-04 02:38:57.000 467 2014-11-05 02:15:50.000 467 2014-11-05 17:14:25.000 , need output useid checkin checkout 467 2014-10-24 17:04:43.000 2014-10-25 02:31:40.000 467 2014-10-27 17:22:06.000 2014-10-28 02:55:57.000 467 2014-10-28 17:57:12.000 2014-10-29 02:36:30.000 and if there no check out 2014-11-05 17:14:25.000 set checkout null tanks help
not knowing issues is, think need.
select userid, min(checktime) checkin, max(checktime) checkout checkinout [checktime] > '2014-10-24' , datepart(hh,min(checktime)) >= '17' , datepart(hh,min(checktime)) <= '22' , datepart(hh,max(checktime)) >= '17' , datepart(hh,max(checktime)) <= '22' , userid = '467' order checkin and if want users not 467
select userid, min(checktime) checkin, max(checktime) checkout checkinout [checktime] > '2014-10-24' , datepart(hh,min(checktime)) >= '17' , datepart(hh,min(checktime)) <= '22' , datepart(hh,max(checktime)) >= '17' , datepart(hh,max(checktime)) <= '22' grouping checktime, userid order checkin sql sql-server select
No comments:
Post a Comment