please Solve my issue,
I have Table name Record which has the following columns,
Empid in number column, dat in timestamp
which has the following values - empid dat
-
====== ====
-
101 4/9/2012 9:48:54 AM
-
101 4/9/2012 9:36:28 AM
-
101 4/9/2012 6:16:28 PM
-
101 4/10/2012 9:33:48 AM
-
101 4/10/2012 12:36:28 PM
-
101 4/10/2012 8:36:12 PM
-
101 4/11/2012 9:36:28 AM
-
101 4/11/2012 4:36:22 PM
Here I need to display the following columns,
empid,min(dat) as start,max(dat) as end and difference(max(dat)-min(dat) for each day,
Here 3 different days are exists so It should return 3 records with the above mentioned columns,
Please Help me to get this.
Thank you,
Regards,
Gurujothi
Hi Rabbit,
this code solved my issue, - select empid,trunc(dt) as Dat,
-
to_char(min(dt),'hh:mi am') as Firstintime,
-
to_char(max(dt),'hh:mi am') as Lastouttime,
-
to_char(trunc(sysdate) + (max(dt) - min(dt)),'hh24:mi') as TotalHours
-
from trans
-
group by trunc(dt),empid
Thank you,
regards,
gurujothi
5 7228
Do just that in an aggregate query. Just group by the empid, year, month, and day of the date.
Hi Rabbit,
Thank you for your response,can you post the query here.?
I do not give out code unless the poster has shown they have attempted the solution themselves.
Hi Rabbit,
If I use the following query am getting the output, - select empid,trunc(dt) as Dat,
-
min(dt) as Firstintime,
-
max(dt) as Lastouttime,
-
to_number(max(dt) - min(dt))*24 as TotalHours
-
from trans
-
group by trunc(dt),empid
For firstintime it displaying output as 3/29/2012 9:12:57 AM but I need only 9:12:57 AM for this column,
For lasttintime it displaying output as 3/29/2012 9:24:24 PM but I need only 9:24:24 PM for this column,
For Totalhours it displaying output as 12.1908333333333 but I need only in hour and minute format i.e 9.12 for this column
How to get this output format?
regards,
gurujothi
Hi Rabbit,
this code solved my issue, - select empid,trunc(dt) as Dat,
-
to_char(min(dt),'hh:mi am') as Firstintime,
-
to_char(max(dt),'hh:mi am') as Lastouttime,
-
to_char(trunc(sysdate) + (max(dt) - min(dt)),'hh24:mi') as TotalHours
-
from trans
-
group by trunc(dt),empid
Thank you,
regards,
gurujothi
Sign in to post your reply or Sign up for a free account.
Similar topics
by: AzGhanv/. |
last post by:
Hi,
I m searching for some Script / Function ... to find difference in data
b/w 2 similar tables (exactly same fields structure) in sql 2000.
plz update me asap !
thanks in advance !
|
by: gnuoytr |
last post by:
i can't find either confirmation or contradiction in the docs
available. a colleague asserts that a column defined TIMESTAMP
is always and automatically updated when any column in the row
is...
|
by: Marcus Leon |
last post by:
Access freezes when we attempt to link to and then open an Oracle
table that has a Timestamp column. Does anyone know why?
This issue does not occur if you attempt to link to and open a table...
|
by: Prafull Soni |
last post by:
hi
Can anyone give me program to find difference between two dates?
thanks
Prafull Soni
|
by: Ali Baba |
last post by:
Hi,
Is there is equivalent of VB's DateDiff() method in C#. I need to find
difference in months between two dates that are years apart. Docs says
that I can use TimeSpan like:
TimeSpam ts =...
|
by: Mal Ball |
last post by:
I hope I have the right forum for this question. I have an existing Windows
application which uses a SQL Server database and stored procedures. I am now
developing a web application to use the same...
|
by: Konstantinos Pachopoulos |
last post by:
Hi,
does any body now any such algorith? to find difference in days from
YYYYMMDD to YYYYMMDD?
Or just an algorithm, that converts YYYYMMDD to seconds since the epoch?
Thanks
|
by: manishamca |
last post by:
can anyone say me how to find the difference of values present in two textbox and display the result in the third textbox.
for eg:
<input type=text name=t1 value=123>
<input...
|
by: Frank Swarbrick |
last post by:
We're trying to take advantage of the new ROW CHANGE TIMESTAMP option.
Here is a simple table:
CREATE TABLE "ACCTASGN"."NUMBER_STATUS" (
"STATUS_CODE" CHAR(1) NOT NULL ,
"STATUS_DESCRIPTION"...
|
by: db2dbdba |
last post by:
How can I find time/timestamp of instance creation on DB2 LUW?
I thought I might find this info on dbm snapshot but no luck. it gives only the information on last start time of instance ?
I...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |