Return Results Where Employee ID That Has 2 Different Timezone IDs On Same Date
Jun 21, 2012
I have a table with the following columns
EMPLOYEEIDNUMBER(12,0)
PUNCHDTM DATE
TIMEZONEIDNUMBER(12,0)
I want to return any results where any employee id that has 2 different timezoneid's on the same date. I would actually like, if its possible, to select these entries to display on one row per employee per day. So for example
EMPLOYEEID - PUNCHDTM - TIMEZONEID - PUNCHDTM - TIMEZONEID
12345 - 6/20/2012 5:00 am - 123 - 6/20/2012 10:00am - 456
To me who is newer with SQL this sounds like i would be 'joining' the table to itself so i've searched for that but not found what i need.
View 3 Replies
ADVERTISEMENT
Jul 15, 2013
I've been having an issue and cannot figure it out for the life. First, here's an example set of the data I'm using so you can see exactly what I'm asking.
Emplid Effdt Effseq
10001 '01-JAN-99' 0
10001 '01-JUL-11' 0
10001 '01-JUL-11' 1
10001 '01-JUL-11' 2
10001 '01-JUL-12' 3
What I need to do here, is obtain 3 rows. The 3 rows I need are rows 1, 4, and 5. I need row 1 because its a completely different date. I need row 5 for the same reason: it's a different date. The issue arises with how I can obtain row 4. The problem is that because rows 2, 3, and 4 all have the same effective date(effdt), SQL Developer just returns one of those rows. Because those 3 rows all have the same effective date(effdt), the tie breaker becomes the effective sequence(effseq) number. When the effective date(effdt) is the same, you need to grab the maximum effective sequence(effseq) number and return that whole row's results such as the emplid, effdt, and effseq. It seems so straight forward and something you can use a subquery for, but its not that simple. Note, that you can specifically use the emplid = 10001 in any specific form because there's many employee id's. Also, the rows will not be in a specific order so you cannot just always grab rows 1, 4, and 5. Some employees may only have a single row in the database, and some may have 50 rows. Everything solely depends on the combination of employee id(emplid), effective date(effdt), and effective sequence(effseq) as the tie breaker.
View 7 Replies
View Related
May 27, 2008
I have this query that returns results that contain duplicates(somewhat). I only want either the FIRST or LAST (either one is fine). Here is the query:
select unique PLLA.attribute4, PLA.item_description from po_lines_all PLA, po_line_locations_all PLLA
where PLLA.po_line_id = PLA.po_line_id
and PLLA.attribute4 is not null
So my output is something like this:
RCE12 This is an item for AUL1
RCE13 This is an item for PWEILL
RCE14 This is an item for AUL1
I just want either the RCE12 or RCE14 record and not both since they both have the same description.
View 2 Replies
View Related
May 21, 2013
Is there any way of returning output parameter values to calling environment before completion of procedure execution. I may achieve it by using GTTs, looking for any other way (because calling environment again need to issue select statement to retrieve data from GTT).
Example case:
Procedure have multiple ref cursors as out parameters.
....
...
if exp1=exp2
then
open v_ref_var1 for select ...from ... ;
end;
[code]..........
If the first if condition satisfies, ref cursor - v_ref_var1 data should be immediately available for the calling environment.
View 4 Replies
View Related
Dec 10, 2011
I have a need to query a real time production database to return a set of results that spans a three day period. When the three days are consecutive it's easy but sometimes there is a 1 or two day gap between the days. For example I'm querying results from a group of people that work between Tuesday and Saturday. On a Wednesday I need t produce a set of results that spans Tuesday of the current week, and Saturday and Friday of the previous week; on Thursday I need to produce a set of results that that spans Wednesday and Tuesday of the current week and Saturday of the previous week.I'm using SQL Developer to execute the code.
View 7 Replies
View Related
Aug 11, 2013
/* Formatted on 2013/08/11 18:46 (Formatter Plus v4.8.8) */
CREATE PROCEDURE p_get_name (
p_empno IN OUT NUMBER,
p_name OUT VARCHAR2,
p_err OUT NUMBER
[code].......
Note:- I want to print ename and salary of emp using empno as a input but i dont want to declare extra variable for salary , i want to print salary using empno but when i execute this procedure. It gives value of empno in salary. Don't Know Why , how can i print salary of emp using empno as input without declaring extra variable for salary.
View 25 Replies
View Related
Feb 9, 2012
based on the following information
grade lowsal highsal
------ ----- ------
1 700 1200
2 1201 1400
3 1401 2000
4 2001 3000
5 3001 9999
for the employee table to assign grade for each employee based on his salary the following plsql procedure is giving error:
-----------------------------------------------------------
CREATE OR REPLACE PROCEDURE GRADE(EID IN NUMBER,BONUS OUT NUMBER) IS
vGRADE NUMBER(8,2);
vSAL NUMBER(8,2);
BEGIN
vGRADE=1
SELECT SAL INTO vSAL FROM EMP WHERE EMPNO=EMPID;
IF vSAL<= 700 THEN
vGRADE:=1;
ELSEIF vSAL<= 1201 THEN
[code]....
View 4 Replies
View Related
Apr 30, 2012
My version of the Database:
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
PL/SQL Release 10.2.0.5.0 - Production
"CORE10.2.0.5.0Production"
TNS for Linux: Version 10.2.0.5.0 - Production
NLSRTL Version 10.2.0.5.0 - Production
I have a staff table with the columns staff_id and completion_date. The completion_date shows the date a staff member completed questionnaire. If the staff member did not complete the questionaire, then the completion_date column will be NULL.
Table Definition:
-- Create table
create table staff
(
staff_id number not null,
completion_date date
);
See attached text file (staff.sql) for Insert Statements.
The result set needs to have the following columns: ReportDate: the Sunday of each week. Completed: The number of staff who have completed the questionnaire by the ReportDate. NotCompleted: The number of staff who did not complete the questionnaire by the ReportDate. Total: The SUM of Completed and NotCompleted columns.
As the number of Completed goes up, the number of NotCompleted goes down. Eventually Completed will equal Total and NotCompleted goes to zero.
The result set would look similar as follows and used to generate a bar graph chart:
ReportDateCompletedNotCompletedTotal
2012-Apr-01814651473
2012-Apr-082214511473
2012-Apr-1514413291473
2012-Apr-2242010531473
2012-Apr-295788951473
View 8 Replies
View Related
Sep 1, 2010
This query returns 2 rows and the output is displayed as well. how I can return just the first row where the max end_date is 4/30/2011?
select
pt.customer_number,
pt.customer_name,
lease.lease_number,
lease.lease_name,
lease.property_name_disp,
lease.location_code_disp,
MAX(pt.end_date) end_date,
pt.attribute1 Disabled
[code]...
View 19 Replies
View Related
Jun 15, 2010
I'm working on a Oracle Database, and I'm gettin incorrect results when including a date field in the select list which is NULL in the table.
This works correctly and returns exactly one row:
SELECT firstField FROM table WHERE firstField = 'value'
while this doesn't and returns no rows:
SELECT firstField, secondField FROM table WHERE firstField = 'value'
Where secondField is of type date and its value is NULL (00-000-00). Note that the only thing that changes is the select list.
View 6 Replies
View Related
Mar 23, 2011
I'm trying to return a field in a date format, but my minutes keep returning as 03. See example below:
TO_CHAR (i.editdate, 'mm/dd/yyyy HH24:MM:SS') AS "Date",
Actual data field in the table contains:
10/27/2010 1:07:42 PM
Data returned is:
10/27/2010 13:03:42
Why are the minutes incorrect?
View 10 Replies
View Related
Apr 21, 2013
i have written an sql to look as sales orders but i want it to only return the last 12 months worth of sales for the date its run, the date file [sdtrdj] is julian date so i used to_char to conver it to dd-mm-yyyy how can i get it to only return the last 12 months from the date its run
select
sdshan As "Location", sddcto As "Order Type", sddoco As "Order Number",sdlitm As "Product Code", sddsc1 As "Product Description",
to_char(to_date(sdtrdj + 1900000, 'yyyyddd'),'DD-MM-YY')As "Order Date", sduorg As "Order Qty", sdaexp As "Extended Amount", sdsoqs As "Quantity Shipped",
ibsrp4 As "Srp4", ibsrp6 As "Srp6", ibsrp7 As "srp7", ibsrp9 As "Srp9", ibsrp0 As "srp10", sdsrp2 As "Franchise"
From proddta.f4211, proddta.f4102
Where sdmcu = ' UKC001'
and sddcto = 'KO'
and sdlitm = iblitm and sdmcu = ibmcu
and sdsrp2 In ('504','973','322','236','232','856','233','566','590','470','343','266','279')
View 3 Replies
View Related
Nov 18, 2011
I have a sub query (already dervived from several other tables) that has a list of children in with the date they started their course (tableofchildren). Child IDs may be duplicated in this query but each record will have unique start dates per child ID.
I have a second sub query which lists workers involved with the children in the first query (tableofworkers). A worker may be responsible for more than one child but has the unique child in the record to identify involvement with the child.
I need to join these queries together to return the child's record with the WorkerName and the AllocatedStartDate of the worker who was most recently involved with the child prior to the date (EnteredCourseDate) the child started their course (OutputWanted) - the worker associated with the child when they started their course.
A couple of points - I need to deploy this into another reporting application that doesn't support cursors etc or the 'With' operator. Also, I tend to join tables/queries in the Where clause so if it's possible that way that would be great.
OC.
create table tableofchildren
(ChildID varchar(20),
ChildName varchar (50),
[Code].....
View 13 Replies
View Related
Feb 15, 2013
I have an attribute in my DB called start_date of type date.I want a query that return the difference between the start_date and the current date.for example if start_date = 2/14/2013 *2*:35:00 PM and the current date = 2/14/2013 *1*:35:00 PM the query returns 1.
I want the result in hours.
View 13 Replies
View Related
Nov 25, 2011
I have a table like below,I want retrieve each employee age ,from db column
SQL> select * from dob;
ENAME DB
---------- ---------
vishal 12-MAR-90
jeya 30-MAR-73
vasanthi 17-APR-80
mangai 25-NOV-81
poorna 18-AUG-80
vinod 20-AUG-81
nanthini 01-JUN-86
karthick 20-MAR-88
View 4 Replies
View Related
Oct 17, 2012
In Apex 4.2, the item validation of "Function Returning Boolean" and "Function Returning Error Text"; They seam to be backwards.
Is there a simple statement that can be used to fix this in the apex dictionary?
View 1 Replies
View Related
May 23, 2013
I need the timezone of the server that the DB sits on. I don't want the offset. I need the region name. This is because some regions use daylight savings time and some do not. Plus an SA can change the time of the OS. Another company manages our servers and DBs in production and we don't have contact with them. We could use a lookup talbe and just populate it, then update it when we find out what it is in production. The problem is that I have seen cases where the timezone on servers change. Considering the lack of contact between the teams, we really need a reliable way to get the timezone out of the DB.
We tried several ways. My list is below and I explain why this is not working.
examples:
sessiontimezone: this is the timezone of my server. In theory it should be the same as the DB. We cannot take the risk that this will be out of sync. dbtimezone: This gives the offset. Such as -5:00 for US EST. There are multiple regions that have this. Some do not use daylight savings time and some do. We would need America/New York instead.
sessiontimezone gives the timezone setting for the client. This can be altered.
dbtimezone just gives the offset such as -5:00
We get data feeds from different parts of the world. We get some data based data that is local to that regions timezone. We need to partition on this field. So we need to add a field to the DB and normalize it to the time local to our DB Server. So if we get a record from california and the DB is on a server in US EAST, we add 3 hours. The offset won't work...
1. a timezone that we are getting from may not be in daylight savings time. We are partitioning by hour.
2. We would hit daylight savings time in New York before we hit it in California, so we would need to account for that in the math.
This hourly partition is a fixed and hard requirement. We need this to be absolutely accurate.
Here is what we tried:
What I want (pseudo-code): “Select XXX as timezone_region_name” to return “America/New_York” or “UTC”. It may be that the timezone was not set for the database at install time, and if it were, these queuries would work.
-- FAILED
SELECT DBTIMEZONE FROM dual;
--FAILED
select systimestamp, to_char(systimestamp, 'TZR'), extract (timezone_region from systimestamp) from dual;
--FAILED
SELECT systimestamp
AT TIME ZONE DBTIMEZONE "DB Time"
FROM DUAL;
--FAILED
select to_char(systimestamp, 'TZR') from dual;
View 7 Replies
View Related
Jun 12, 2013
When I try to store the xml as clob with element:
<revisedDate version="1">2013-06-10T11:00:00+11:00</revisedDate>
It is throwing �ORA-01830: date format picture ends before converting entire input string�
But when I insert with
<revisedDate version="1">2013-06-10T11:00:00+05:30</revisedDate>,
it is getting inserted successfully.
PS: my db timezone is +00:00
View 1 Replies
View Related
Mar 6, 2013
If I run the following query it's executing fine.
SELECT CAST(( FROM_TZ(CAST(SYSDATE AS TIMESTAMP),'CST') AT TIME ZONE ('Japan'))
AS DATE) FROM DUAL;
If I run the following query,I am getting the error.
ORA-01882: timezone region not found
SELECT CAST(( FROM_TZ(CAST(SYSDATE AS TIMESTAMP),'LMT') AT TIME ZONE ('philippines'))
AS DATE) FROM DUAL;
What is the timezone for Philippines.
View 6 Replies
View Related
Sep 14, 2012
I have an interesting problem. I have a server in the UK and I have three databases globally - UK (FINUKQ1), NY (FINNYQ1) and TK (FINTKQ1). The NY and TK databases will be migrated to the UK server as part of a consolidation project. Obviously, Time Zones and DST are the biggest concern for me.Here was my plan for the implementation (concentrating on Time Zone/DST issues).
Added to .profile:
--------------------
if [[ "$ORACLE_SID" = "FINTKQ1" ]]; then
export TZ="Asia/Tokyo"
elif [[ "$ORACLE_SID" = "FINNYQ1" ]]; then
export TZ="America/New_York"
else
unset TZ
fi
echo "TZ=$TZ"
Once environment has been set start database and listener.
Change database TZ:
-----------------
alter database set time_zone='Asia/Tokyo';
alter database set time_zone='America/New_York';
Check database TZ:
select dbtimezone from dual;
Add trigger:
------------
CREATE OR replace TRIGGER sys.timezone_check
AFTER startup ON DATABASE
DECLARE
[code]...
The trigger was there to put the database in restricted session if it is started in the wrong TZ and an error written to the alert log. The check was done on the dbtimezone and the dbname. Quite simple. Only issue is that it doesn't work as I wanted as dbtimezone and TZ are separate and disparate entities. i.e. I can start the TK database up in UK time (which will be incorrect for this project), and check the dbtimezone and it will show as 'Asia/Tokyo'.
Is there a better way of checking? Any trigger like this to compare TZs etc?
View 2 Replies
View Related
Jan 7, 2013
I am using the below query to get time stamp along with time zone format.
>>SELECT CURRENT_TIMESTAMP FROM DUAL
Now the requirement i got is i need to get convert the format in DD-MON-YY, HH:MM:SS, Timezone (GMT or PST)
how to convert this format. Or is there any alternative time stamp option to do conversion.
View 5 Replies
View Related
Oct 10, 2012
I've written this code to present the problem:
declare
region_date varchar2(100);
region varchar2(100);
offset_result varchar2(100);
begin
region_date := '2013-04-07 01:59 Australia/Sydney';
region := 'Australia/Sydney';
select
to_char(
[code]....
What I want to do is to use the variable "region" for the timezone specification as well,And I seem to be unable to, and don't understand why.....
why when I get an "ORA-00907: missing right parenthesis" with this value,Whereas, it works when I put "AT TIME ZONE 'Australia/Sydney'" there?
View 3 Replies
View Related
May 24, 2012
I have one issue My server is in france and it is in french timezone but when I query for sysdate it returns US time.
In '/etc/sysconfig/clock/'
Zone= europe/paris
UTC= true
echo $TZ variable is returning nothing.
sysdate = us time
systimestamp= us time
current_timestamp = french time
current_date = french time
dbtimezone= europe/warsove, sessiontimezone=+2.00( which is also europe timezone offset)
tz_offset(dbtimezone)=+2.00, tz_offset(sessiontimezone)= +2.00 i.e europe
os timezone= europe/paris.
This command "./emctl config agent getTZ" is also returning timezone as europe/paris
Also in "emd.properties" file "agentTZRegion" parameter is set to europe/paris
Oracle version= 11.2.0
Now I don't understand why this sysdate and systimestamp is returning "US time zone" while everything else is returning french time zone.
View 9 Replies
View Related
May 15, 2011
I'm in the process of testing a restore/recover from a simulated full system and media loss. A level 0 backup was taken from the server, and I'm trying to restore/recover to a point in time on a second server. I have created the database (with the same name) and have been able to successfully restore both the controlfile and spfile from the autobackup.
how does RMAN treat the "set until time"? The level 0 was taken on a database/server that is in CST while the database I'm trying to do a restore/ recover to is in EST. So when trying to do a point in time recovery, should I specify the time in EST or CST?
View 2 Replies
View Related
Jan 20, 2013
I'm going to migrate my current db 9.2.0.8 (Timezone version is 1!) to a new server 11.2.0.3, so I was wondering if I must upgrade timezone version of my current 9iR2 to version 4! Before upgrade it...Btw my new server has timezone v14.
View 4 Replies
View Related
Aug 31, 2010
How to change db timezone parameter. My application team has asked me to change the db timzone parameter by following sql.
ALTER database SET TIME_ZONE = '+10:00';
Is this way is the correct one , and do we have any impact on database and does it require a db bounce.
View 2 Replies
View Related
Oct 22, 2011
Order time is not properly displayed in the local timezone format and day light saving calculation is also another issue. Description:
We have web application & a centralized database where users can create orders globally. When orders are created time is saved in UTC format in the centralized global database.
somehow along with the UTC order time, timezone description is also being stored in one of the Database table as
UTC time as: '28-NOV-2010 11:24:54 PM'
Timezone description:
(GMT) Casablanca, Monrovia
(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London
(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna
(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague
(GMT+01:00) Brussels, Copenhagen, Madrid, Paris
(GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb
(GMT+01:00) West Central Africa
(GMT+02:00) Athens, Beirut, Istanbul, Minsk
(GMT+02:00) Bucharest
(GMT+02:00) Cairo
(GMT+02:00) Harare, Pretoria
(GMT+02:00) Helsinki, Kyiv, Riga, Sofia, Tallin
.....
...
With this information how can I map timezone description to V_$TIMEZONE_NAMES. I read Oracle automatically converts to local timezones by considering day light saving timings when TZNAME is given as input with the datetime. by using above timezone descriptions how can I get TZNAMES which are in V_$TIMEZONE_NAMES.
View 1 Replies
View Related
Mar 6, 2012
I have a requirement in which a particular a timestamp column (date1) whose values are in CET timezone needs to be converted to EST and day light savings should be taken care of in the conversion logic. I should not use any ddl statements for altering the timezone and all.
View 9 Replies
View Related
Jun 14, 2012
I am having an issue to connect my C++ application to my Oracle DB. When my code calls
oracle::occi::Environment::createEnvironment(),
I get an error "ORA-01804: failure to initialize timezone information".
The application works on other people's Windows machine with their Oracle DB. But it doesn't work from my machine connecting to their Oracle instance. So I guess the issue does not come from my instance but rather from my Oracle dlls maybe?
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
View 0 Replies
View Related
Jun 1, 2010
I'm trying to work out how to take a table like this:
IDDate
12502-Feb-07
12516-Mar-07
12523-May-07
12524-May-07
12525-May-07
33302-Jan-09
33303-Jan-09
33304-Jan-09
33317-Mar-09
And display the data like this:
IDPeriodPeriod StartPeriod End
125102-Feb-0702-Feb-07
125216-Mar-0716-Mar-07
125323-May-0725-May-07
333102-Jan-0904-Jan-09
333217-Mar-0917-Mar-09
As you can see, it's split the entries into date ranges. If there is a 'lone' date, the 'period start' and the 'period end' are the same date.
View 13 Replies
View Related