![]() | |
#1
| |||
| |||
|
|
name | login time | logout time | |
|
a | 2007-11-10 12:00:00 | 2007-11-10 16:00:00 | |
|
b | 2007-11-10 15:00:00 | 2007-11-10 18:00:00 | |
#2
| |||
| |||
|
|
Hi, I am creating a attendance sheet software for inhouse use. my data is like this:- ------------------------------------------------------------------------------------------------ | name | login time | logout time | ------------------------------------------------------------------------------------------------ | a | 2007-11-10 12:00:00 | 2007-11-10 16:00:00 | ------------------------------------------------------------------------------------------------ | b | 2007-11-10 15:00:00 | 2007-11-10 18:00:00 | ------------------------------------------------------------------------------------------------ My requirement:- I want to generate an hourly report like this:- -------------------------------------------------------------------------------------------- date time range total people logged in --------------------------------------------------------------------------------------------- 2007-11-10 0 -2 0 -------------------------------------------------------------------------------------------- 2007-12-10 2-4 0 -------------------------------------------------------------------------------------------- . . ------------------------------------------------------------------------------------------- 2007-11-10 12-14 1 ------------------------------------------------------------------------------------------- 2007-11-10 14-16 2 -------------------------------------------------------------------------------------------- 2007-11-10 16-18 1 ------------------------------------------------------------------------------------------------ . . --------------------------------------------------------------------------------------------- 2007-11-10 22-24 0 -------------------------------------------------------------------------------------------- This is what I want to creat , but I don't know how can I generate such kind of report. Can you please guide me for the same. Please reply urgently. Thanks & Regards, Bhishm |
#3
| |||
| |||
|
|
Bhishm wrote: Hi, I am creating a attendance sheet software for inhouse use. my data is like this:- ------------------------------------------------------------------------------------------------ | name | login time | logout time | ------------------------------------------------------------------------------------------------ | a | 2007-11-10 12:00:00 | 2007-11-10 16:00:00 | ------------------------------------------------------------------------------------------------ | b | 2007-11-10 15:00:00 | 2007-11-10 18:00:00 | ------------------------------------------------------------------------------------------------ My requirement:- I want to generate an hourly report like this:- -------------------------------------------------------------------------------------------- date time range total people logged in --------------------------------------------------------------------------------------------- 2007-11-10 0 -2 0 -------------------------------------------------------------------------------------------- 2007-12-10 2-4 0 -------------------------------------------------------------------------------------------- . . ------------------------------------------------------------------------------------------- 2007-11-10 12-14 1 ------------------------------------------------------------------------------------------- 2007-11-10 14-16 2 -------------------------------------------------------------------------------------------- 2007-11-10 16-18 1 ------------------------------------------------------------------------------------------------ . . --------------------------------------------------------------------------------------------- 2007-11-10 22-24 0 -------------------------------------------------------------------------------------------- This is what I want to creat , but I don't know how can I generate such kind of report. Can you please guide me for the same. Please reply urgently. Thanks & Regards, Bhishm Your problem is not urgent and I, for one, am offended at your abuse of the term. No production database is down. No house is on fire. No one is drowning. Apologize and you may get some help. That said you don't offer up any of the required DDL or any evidence that you have attempted to solve the problem yourself. Rather it looks like you are either a student trying to cheat or someone unqualified for their job. In either case no one should give you the answer. -- Daniel A. Morgan Oracle Ace Director & Instructor University of Washington damor...@x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Groupwww.psoug.org |
|
a | 2007-11-10 12:00:00 | 2007-11-10 16:00:00 | |
|
b | 2007-11-10 15:00:00 | 2007-11-10 18:00:00 | |
#4
| |||
| |||
|
|
On Nov 20, 7:01 pm, DA Morgan <damor... (AT) psoug (DOT) org> wrote: Bhishm wrote: Hi, I am creating a attendance sheet software for inhouse use. my data is like this:- ------------------------------------------------------------------------------------------------ | name | login time | logout time | ------------------------------------------------------------------------------------------------ | a | 2007-11-10 12:00:00 | 2007-11-10 16:00:00 | ------------------------------------------------------------------------------------------------ | b | 2007-11-10 15:00:00 | 2007-11-10 18:00:00 | ------------------------------------------------------------------------------------------------ My requirement:- I want to generate an hourly report like this:- -------------------------------------------------------------------------------------------- date time range total people logged in --------------------------------------------------------------------------------------------- 2007-11-10 0 -2 0 -------------------------------------------------------------------------------------------- 2007-12-10 2-4 0 -------------------------------------------------------------------------------------------- . . ------------------------------------------------------------------------------------------- 2007-11-10 12-14 1 ------------------------------------------------------------------------------------------- 2007-11-10 14-16 2 -------------------------------------------------------------------------------------------- 2007-11-10 16-18 1 ------------------------------------------------------------------------------------------------ . . --------------------------------------------------------------------------------------------- 2007-11-10 22-24 0 -------------------------------------------------------------------------------------------- This is what I want to creat , but I don't know how can I generate such kind of report. Can you please guide me for the same. Please reply urgently. Thanks & Regards, Bhishm Your problem is not urgent and I, for one, am offended at your abuse of the term. No production database is down. No house is on fire. No one is drowning. Apologize and you may get some help. That said you don't offer up any of the required DDL or any evidence that you have attempted to solve the problem yourself. Rather it looks like you are either a student trying to cheat or someone unqualified for their job. In either case no one should give you the answer. -- Daniel A. Morgan Oracle Ace Director & Instructor University of Washington damor...@x.washington.edu (replace x with u to respond) Puget Sound Oracle Users Groupwww.psoug.org Dear Daniel, I apologize and I also tried a lot of things before writing to the group. I tried to solve the problem in following ways but the problem I face is:- i) Using Group By I only get time where somebody logged in and not the interval where he is logged in, in an interval. Ex. Data:- ------------------------------------------------------------------------------------------------ | a | 2007-11-10 12:00:00 | 2007-11-10 16:00:00 | ------------------------------------------------------------------------------------------------ | b | 2007-11-10 15:00:00 | 2007-11-10 18:00:00 | ------------------------------------------------------------------------------------------------ Result:- ------------------------------------------------------------------------------------------- 2007-11-10 a 12-14 1 ------------------------------------------------------------------------------------------- 2007-11-10 b 14-16 1 -------------------------------------------------------------------------------------------- This is wrong as I am not able to get in what all intervals he is logged in. I can get in what inteval people logged in, but not the intervals where he remains logged in. ii) I tried left join, but didn't succeed. These are the two things I tried. Thanks & Regards, Bhishm |
#5
| |||
| |||
|
|
Hi, I am creating a attendance sheet software for inhouse use. my data is like this:- ------------------------------------------------------------------------------------------------- | name | login time | logout time | ------------------------------------------------------------------------------------------------- | a | 2007-11-10 12:00:00 | 2007-11-10 16:00:00 | ------------------------------------------------------------------------------------------------- | b | 2007-11-10 15:00:00 | 2007-11-10 18:00:00 | ------------------------------------------------------------------------------------------------- My requirement:- I want to generate an hourly report like this:- --------------------------------------------------------------------------------------------- date time range total people logged in ---------------------------------------------------------------------------------------------- 2007-11-10 0 -2 0 --------------------------------------------------------------------------------------------- 2007-12-10 2-4 0 --------------------------------------------------------------------------------------------- . . -------------------------------------------------------------------------------------------- 2007-11-10 12-14 1 -------------------------------------------------------------------------------------------- 2007-11-10 14-16 2 --------------------------------------------------------------------------------------------- 2007-11-10 16-18 1 ------------------------------------------------------------------------------------------------- . . ---------------------------------------------------------------------------------------------- 2007-11-10 22-24 0 --------------------------------------------------------------------------------------------- This is what I want to creat , but I don't know how can I generate such kind of report. Can you please guide me for the same. Please reply urgently. Thanks & Regards, Bhishm |
#6
| |||
| |||
|
|
On Nov 20, 2:11 am, Bhishm <bhis... (AT) gmail (DOT) com> wrote: Hi, I am creating a attendance sheet software for inhouse use. my data is like this:- -------------------------------------------------------------------------------------------------- | name | login time | logout time | -------------------------------------------------------------------------------------------------- | a | 2007-11-10 12:00:00 | 2007-11-10 16:00:00 | -------------------------------------------------------------------------------------------------- | b | 2007-11-10 15:00:00 | 2007-11-10 18:00:00 | -------------------------------------------------------------------------------------------------- My requirement:- I want to generate an hourly report like this:- ---------------------------------------------------------------------------------------------- date time range total people logged in ----------------------------------------------------------------------------------------------- 2007-11-10 0 -2 0 ---------------------------------------------------------------------------------------------- 2007-12-10 2-4 0 ---------------------------------------------------------------------------------------------- . . --------------------------------------------------------------------------------------------- 2007-11-10 12-14 1 --------------------------------------------------------------------------------------------- 2007-11-10 14-16 2 ---------------------------------------------------------------------------------------------- 2007-11-10 16-18 1 -------------------------------------------------------------------------------------------------- . . ----------------------------------------------------------------------------------------------- 2007-11-10 22-24 0 ---------------------------------------------------------------------------------------------- This is what I want to creat , but I don't know how can I generate such kind of report. Can you please guide me for the same. Please reply urgently. Thanks & Regards, Bhishm First, the setup: CREATE TABLE T1 ( USERNAME VARCHAR2(15), LOGIN_TIME DATE, LOGOUT_TIME DATE); INSERT INTO T1 VALUES( 'a', TO_DATE('2007-11-10 12:00','YYYY-MM-DD HH24:MI'), TO_DATE('2007-11-10 16:00','YYYY-MM-DD HH24:MI')); INSERT INTO T1 VALUES( 'b', TO_DATE('2007-11-10 15:00','YYYY-MM-DD HH24:MI'), TO_DATE('2007-11-10 18:00','YYYY-MM-DD HH24:MI')); COMMIT; (SNIP) By also allowing the LOGIN_HOUR to fall between the LOGIN_COUNTER and LOGOUT_COUNTER, or the LOGOUT_HOUR to fall between the LOGIN_COUNTER and LOGOUT_COUNTER (with a slight adjustment), we pick up the missing row. Now, it is a simple matter to find the total number in each time period: SELECT T.CHECK_DATE, TO_CHAR(LOGIN_COUNTER,'99')||'-'||TO_CHAR(LOGOUT_COUNTER,'99') TIME_RANGE, COUNT(*) TOTAL_PEOPLE FROM (SELECT TRUNC(LOGIN_TIME) CHECK_DATE, TO_NUMBER(TO_CHAR(LOGIN_TIME,'HH24')) LOGIN_HOUR, TO_NUMBER(TO_CHAR(LOGOUT_TIME,'HH24')) LOGOUT_HOUR FROM T1) T, (SELECT (LEVEL-1)*2 LOGIN_COUNTER, (LEVEL-1)*2+2 LOGOUT_COUNTER FROM DUAL CONNECT BY LEVEL<=12) C WHERE (C.LOGIN_COUNTER BETWEEN T.LOGIN_HOUR AND T.LOGOUT_HOUR AND C.LOGOUT_COUNTER BETWEEN T.LOGIN_HOUR AND T.LOGOUT_HOUR) OR T.LOGIN_HOUR BETWEEN C.LOGIN_COUNTER AND C.LOGOUT_COUNTER-1 OR T.LOGOUT_HOUR BETWEEN C.LOGIN_COUNTER+1 AND C.LOGOUT_COUNTER GROUP BY T.CHECK_DATE, TO_CHAR(LOGIN_COUNTER,'99')||'-'||TO_CHAR(LOGOUT_COUNTER,'99') ORDER BY 1, 2; CHECK_DAT TIME_RA TOTAL_PEOPLE --------- ------- ------------ 10-NOV-07 12- 14 1 10-NOV-07 14- 16 2 10-NOV-07 16- 18 1 The above likely is not the only solution to the problem. Charles Hooper IT Manager/Oracle DBA K&M Machine-Fabricating, Inc.- |
![]() |
| Thread Tools | |
| Display Modes | |
| |