SQL & PL/SQL :: Get Continuous Dates With Same Status Value

Feb 23, 2012

I'm looking for a way to get continuous dates as a period in the result.My tabledata contains a date and a status, I want to get continuous dates with the same status value.

That's my tabledata:
select * from (
select to_date('01022012', 'ddmmyyyy') as thedate, 1 as status from dual
union select to_date('02022012', 'ddmmyyyy') as thedate, 1 as status from dual
union select to_date('03022012', 'ddmmyyyy') as thedate, 2 as status from dual

[code]...

THEDATE STATUS
---------- ------
01.02.2012 1
02.02.2012 1
03.02.2012 2
04.02.2012 1
05.02.2012 1

[code]...

And that's the result I am looking for:
select * from (
select to_date('01022012', 'ddmmyyyy') as startdate,
to_date('02022012', 'ddmmyyyy') as enddate from dual
union select to_date('04022012', 'ddmmyyyy') as startdate,

[code]....

View 6 Replies


ADVERTISEMENT

PL/SQL :: Continuous Data Range Algorithm?

May 3, 2013

I have in my database table 2 important date columns: StartDate (Not null) and EndDate(Allowed Null).I want to ensure that all records in the table would always create perfect contiues date ranges with no holes inside.Wor example there may not be records [1-may..1-may, 3-may-...] because there would be a hole [2-may...2-may]. Holes are not allowed.

And overlapping is not allowed, for example [1-may..1-may, 1-may-2may, 3-may-...] is not allowed because overlapping occures on day 1-may. Overlapping and holes are not allowed. But it is allowed that table has no records at all. But all DML manipulations with existing records must ensure that overlapping and holes won't occur.How to write such check? How to ensure that data ranges would stay continous with no holes and no overlaps?

View 10 Replies View Related

Finding Individual Dates Having Dates Plus 2 Days

Jan 26, 2011

I want to find the dates which have a date plus with in 2 days after this date. I mean group by 3 days each even the date i missing between two days. Actualy I want to find the start date where the employ was missing on job.

Basic concept is employes have allowed to use 10 personal leaves of a year. Each leave can be use for maximum 3 days.

If employ did not come on the job for one day or two days or three days, it shoul be count as ONE personal leave. And If employ is missing at job for four or five days, it should be count as 2 personal leaves.

seq date
------------------------------
101.01.10

205.01.10
306.01.10

410.01.10
512.01.10

613.01.10
714.01.10
815.01.10

916.01.10
1018.01.10

1119.01.10
1220.01.10
1321.01.10

1423.01.10

1526.01.10
1627.01.10

1729.01.10
1831.01.10

The result should be (Don't use Pl/Sql)

seq date
------------------------------
101.01.10
205.01.10
310.01.10
413.01.10
516.01.10
619.01.10
723.01.10
826.01.10
929.01.10

After finding these days I want to select the starting date of 5th personal leave. (which is 16.01.10).

I am not a expert of using SQL, but I think it could be possible with using partitioning a table on the givin reslult and further partition the reslut on rownum() as rn and the using case statement where rn = 5.

View 2 Replies View Related

SQL & PL/SQL :: Split A Date Into New Dates According To Black Out Dates?

Mar 10, 2011

Split a date into new dates according to black out dates!

Here is my tables:

CREATE TABLE travel
(
start_date,
end_date
)
AS
SELECT DATE '0000-01-01', DATE '9999-12-31' FROM DUAL;

[code]....

I have lets say a "travel date" and black out dates. I will split the travel date into pieces according to the black out dates.

Note: Travel Date can be between 0000-01-01 - 9999 12 31

Sample:

Travel Date:

Travel | START DATE | END DATE
T | 2011 01 04 | 2011 12 11

Black Out Dates:

BO | START DATE | END DATE
A | 2010 11 01 | 2011 02 11
B | 2011 01 20 | 2011 02 15
C | 2011 03 13 | 2011 04 10
D | 2011 03 20 | 2011 06 29

Excepted Result:

New Travel | START DATE | END DATE
X1 | 2011 02 16 | 2011 03 12
X2 | 2011 06 30 | 2011 12 11

Visually:

Travel Date : -----[--------------------------]--

A : --[------]-------------------------
B : ------[---]------------------------
C : --------------[---]----------------
D : ----------------[------]-----------

Result :

X1 : -----------[--]--------------------
X2 : -----------------------[--------]--

Sample 2:

Travel Date : -[--------------------------------]--

BO Date A : ----[------]-------------------------
BO Date B : -------------------------[---]-------
BO Date C : ----------------[---]----------------
BO Date D : ------------------[------]-----------

Result X1 : -[-]-------------------------------
Result X2 : -----------[--]--------------------
Result X3 : -----------------------------[--]--

How can I do it using PL SQL ?

View 5 Replies View Related

Grouping Data By Continuous Intervals Of TimeStamp

Nov 26, 2010

I am having past data in a table say for one year. each row is having a timestamp column. Now i need to calcute avg of data for every time interval betwwen start date and end date.

time interval can be in minute, hours, days or months..in case of hours,days and months , i need to convert to minutes and group based on that interval.

View 11 Replies View Related

SQL & PL/SQL :: Find Query To Create Gap In Continuous Series?

Jan 16, 2013

I need to find a query to create a gap in continuous series. So that i can fill this gap with a new record.

Attached here is the test sql.

Sample Data is

test@orcl>select * from sales_mst;

NO VDATE T
---------- --------- -
1245 07-JAN-13 N
1246 07-JAN-13 N
1247 07-JAN-13 R
1248 07-JAN-13 N

[code]...

10 rows selected.

test@orcl>select * from sales_dtl;

NO CODE QTY RATE
---------- ---------- ---------- ----------
1245 11 60 600
1246 12 55 450
1246 11 45 600
1247 13 50 250
1247 11 60 600
1248 11 45 600
1249 12 55 450

[code]...

16 rows selected.

Required Out Put

test@orcl>select * from sales_mst;

NO VDATE T
---------- --------- -
1245 07-JAN-13 N
1246 07-JAN-13 N
1247 07-JAN-13 R
1248 07-JAN-13 N
1251 08-JAN-13 N
1250 08-JAN-13 R
1253 08-JAN-13 N
1252 09-JAN-13 R
1254 09-JAN-13 N
1255 09-JAN-13 N

10 rows selected.

test@orcl>select * from sales_dtl;

NO CODE QTY RATE
---------- ---------- ---------- ----------
1245 11 60 600
1246 12 55 450
1246 11 45 600
1247 13 50 250
1247 11 60 600
1248 11 45 600
1251 12 55 450
1251 11 45 600

[code]...

16 rows selected.

Update or move only those records which have Type 'N'. I have tried the following query but it is giving me an error.

test@orcl>ALTER TABLE
sales_dtl
DISABLE CONSTRAINT
fk_sales_dtl_no;
test@orcl>update sales_mst set no=no+1 where type='N' and vdate > '07-JAN-13';
*
ERROR at line 1:
ORA-00001: unique constraint (TEST.PK_SALES_MST_NO) violated

View 15 Replies View Related

Forms :: Continuous Update Of Calculated Field?

Aug 6, 2013

I have seen in probably VB or Dot net software being used at some premises that there "formula computation is live and interactive".

What i means that suppose a cashier has made invoice having total of 83$. Mow in the text box for entering amount received, the cashier is about to enter 100 but surprisingly the returned value/remaining value (total invoice - amount received) is being computer LIVE.

This is what happens.

1) The cashier entered 1 and the remaining value instantly showed 82 (83-1)
2) then on other key stroke of 0 by cashier and then then the remaining value instantly showed 73 (83-10)
3) then on other key stroke of 0 by cashier and then then the remaining value instantly showed 17 (83-100)

Hence a continuous updation/changing of the remaining value on every key stroke is observed.

View 3 Replies View Related

SQL & PL/SQL :: Query To Find Continuous Holidays From Holiday Master

Nov 9, 2011

I've a holiday master in which date of holiday is present. It also contain all Sundays.

I've a process which is not executed on Sundays and Holidays. After holidays it must process all data.

E.g.

01-NOV-2011 --Holiday
02-NOV-2011 --Holiday
03-NOV-2011 --Sunday

On 31-OCT-2011 Process is executed for same day data. Since 1,2-Nov are holidays and 3-nov is Sunday. The process will be executed on 04-Nov-2011 for data between 01-Nov-2011 to 04-Nov-2011. On 05-nov-2011 process will be executed for same day data. Then the process will be executed on 07-nov for 6,7-nov data, because 6-nov was Sunday.

It's like

SELECT *
FROM TABLE_NAME
WHERE BUSINESS_DATE BETWEEN LV_START_DATE AND LV_END_DATE ;

How to select this LV_START_DATE, LV_END_DATE i.e. MIN & MAX date for a topmost continuous range less than the business date.

Sample Data.
.
.
01-NOV-2011
02-NOV-2011
03-NOV-2011
06-NOV-2011
.
.

View 6 Replies View Related

SQL & PL/SQL :: Reading Streaming Continuous Binary Data From A Website?

Jan 26, 2011

Is it possible to read streaming continuous binary data from a web site using PL/SQL?

View 8 Replies View Related

Reports & Discoverer :: Continuous Pages Not Printing In Exact Pre-printed Area

Nov 29, 2011

I have a Invoice Report, i will give the parameters.

From_Inv_No:
To_Inv_No:
From_Inv_Date:
To_Inv_Date:

so i will give 10 invoices with dates in the above parameters to generate the report, actually the report prints in a pre-printed sheet, well it prints the first page correctly but the second page and continuous pages not printing in the exact pre-printed area. example see below;

(Page2)
506176
28/11/2011
(Preprinted text)INVOICE NO :
INVOICE DATE:

how to give spaces between pages actually every pages it should print 3 to 4 inches gap between the first page but it prints just one inch above the preprinted area. how to make it print without gaps. Additional Information: Preprinted sheet Height 17 inches.

Paper Layout Width 8.5
Height 12

Character Mode

Report Width 80
Report Height 72

for header section, main and trailer sections above readings only given.

View 3 Replies View Related

PL/SQL :: Huge Disk Sort Causing Continuous Full Of Temporary Tablespace

Jan 2, 2013

We are facing problem as temporary tablespace getting full continuously. During below running query, temporary tablespace getting full continuously and now it is not managable so we had stop the processing but we need to resolve this issue as business impact is there.

MERGE INTO HDFCMPR.MPR_TB_MPRMASTER
USING (SELECT /*+ USE_HASH(A,B) FULL(A) FULL(B) */
MER_TRACKID, TRANID, DECODE (UCAF, 'n', NULL, UCAF) UCAF,
A.ID
[code]....

View 5 Replies View Related

Select All Dates Between Two Dates

Oct 22, 2003

How can I select all of the dates between two dates? For example, given the start date 12/2/2003 and the end date 12/5/2003 I want to return:

12/2/2003
12/3/2003
12/4/2003
12/5/2003

Is there a built in function for this? Is there a way for a function to return multiple rows? It has to be a function because I need to use it within other SQL statements.

View 14 Replies View Related

SQL Query To Club Data If Range Data Is Continuous

Nov 26, 2006

For e.g.

if my data is as follows

EX_START_DATE EX_END_DATE EX_CHARGE

5/1/2005 5/5/2005 11:59:59 PM 10
5/6/2005 5/7/2005 11:59:59 PM 10
5/10/2005 5/15/2005 11:59:59 PM 10
5/17/2005 5/19/2005 11:59:59 PM 10
5/20/2005 5/25/2005 11:59:59 PM 20

the record
5/6/2005 5/7/2005 11:59:59 PM 10
is in continuation for
5/1/2005 5/5/2005 11:59:59 PM 10 with the same ex_charge
so i need the output as

5/1/2005 5/7/2005 11:59:59 PM 10
5/10/2005 5/15/2005 11:59:59 PM 10
5/17/2005 5/19/2005 11:59:59 PM 10
5/20/2005 5/25/2005 11:59:59 PM 20

and the remaining rows as it is
(Note :date in mm/dd/yyyy format)

View 6 Replies View Related

Status Online Logfile

Nov 2, 2010

I delete member logfile from disk with statement: shred -fu /u01/app/oracle/redologs/activeredolog/DB1/redo0102.log

But if I check status one logfile with statement:

select status from v$logfile wheremember='/u01/app/oracle/redologs/activeredolog/DB1/redo0102.log';

Status is still null. I think status should be change.

My database is 11.2.0.1 with single instance.

Status is changed after restart instance.

Haw can I monitor status logfiles without restart instance?

View 2 Replies View Related

SQL & PL/SQL :: Batch ID From Child Status

Mar 27, 2013

Im looking for a query which returns the batch for which all the child should either be in 'A_STATUS','B_STATUS' or 'C_STATUS'. In this query im expecting a query which returns batch 2,3 and 4.

create table batch (batchid number);
insert into batch values(1);
insert into batch values(2);
insert into batch values(3);
insert into batch values(4);

[Code]...

View 9 Replies View Related

Forms :: Record Status Bar?

Jun 2, 2011

i am migrating forms 6i to 10g, when i compile one form to checking purpose all are successfully fine but the record status bar not showing there fore message are not appear how to solve this problem

View 1 Replies View Related

SQL & PL/SQL :: Query To Get Overall Status For Clients

Sep 11, 2010

I have a clients table called CLIENTS. One of the fields in this table is called 'status'

I need to set this status field, depending on if the transactions for this client have passed.

The transactions are in a table called TXNS and has fields
client_id, txn_id, txn_status

txn_status can be 'success' or 'failed'

I need to somehow set the overall 'status' field on CLIENTS to success or fail depending on if any transactions failed or not

So for every client I want to list the status, any query that can possible list the overall status for the client?

select client_id, MAX(status)
from txns
group by client_id

but the max(status) bit needs to get the overall status part

View 10 Replies View Related

SQL & PL/SQL :: Monitoring Status Of Procedure?

Feb 24, 2010

I've got a pl/sql procedure that i would like to monitor its progress. Its been running for quite a few hours now and i dont really know if it is stuck in a loop or if it is just taking too long read/execute queries. Is there a way to find out what is the status of the procedure? or what it is currently doing?

I looked at views like v$sessions or v$session_longops but they dont actually tell me what it is currently doing. All of them just point to the call to the pl/sql procedure. Also, is it possible to look at the physical files on the filesystem to know if there is actually any processing going on and files are being written to? Is this possible or a files written to only after a commit?

View 17 Replies View Related

SQL & PL/SQL :: Display Output IDs Which Are Having Status Both Y And N?

May 11, 2012

CREATE TABLE stud(id number,Status CHAR(1))

INSERT INTO stud values(10,'Y')
INSERT INTO stud values(10,'Y')
INSERT INTO stud values(10,'Y')
INSERT INTO stud values(10,'N')

[code]...

ID STATUS

10 Y
10 Y
10 Y
10 N
20 Y

[code]...

I want to display the out put the IDs which are having the status both 'Y' and 'N'The output should be

ID STATUS

10 Y
10 Y
10 Y
10 N
20 Y
20 N
20 N

View 12 Replies View Related

Upgrade :: Get Listener Status?

Oct 31, 2012

We are upgrading 10.2.0.4 enterprise edition single instance to 11.2.0.3 enterprise edition single edition manually. What should the listener status while doing upgradation. This is my first upgradation project.

View 5 Replies View Related

How To Change Remote_login_password File Status

Jan 21, 2006

How to change the status of remote_login_password file!

View 14 Replies View Related

Create A Procedure To Update Status?

Mar 10, 2011

create a procedure that will update the column status from active to closed after every two years.

View 4 Replies View Related

How To Check Status Of Import (old Method) Job

Aug 23, 2011

Question:

How to find out the status of the import job(how much work is done, ETA), i have started the job few days back it still running on the server. i am using import not datapump, because i got the dump which took with export. DB version is 11.2.0.2.0

for datapump i know i can use the following queries, but these are not giving any output l think these are only for datapump

select sid, serial#, sofar, totalwork from v$session_longops;
select sid, serial# from v$session s, dba_datapump_sessions d where s.saddr = d.saddr;

View 1 Replies View Related

How To Change Tablespace Plugged_in (no Status To Yes)

Aug 6, 2010

how to change tablespace plugged_in =no status to yes

View 1 Replies View Related

SQL & PL/SQL :: Change The Temp Table Status?

Jun 21, 2011

In one of the databases, we have created more temp tables as on commit preserve rows. but i want to change the on commit preserve rows to on commit delete rows as per application requirements.I have searched the google but i didnt find any alter scripts for it.?

View 1 Replies View Related

Forms :: How To Check Record Status

Sep 7, 2011

I am manually committing the form by writing commit statement in key - commit trigger for some reason.

Everything is working fine. I want to display a message if some necessary fields are not filled properly, like if a user filled half table and mistakenly he press the commit button. Here I want to show him a message that you can't saved the data because the table is not completely filled.

View 17 Replies View Related

SQL & PL/SQL :: Fetch Records Based On 2 Status

Jan 25, 2013

create table test_exp (oid number, ioid number, status varchar2(20));

Below are the insert statements.

Insert into TEST_EXP (OID, IOID, STATUS) Values (1, 100, 'NEW');
Insert into TEST_EXP (OID, IOID, STATUS) Values (1, 101, 'DISCO');
Insert into TEST_EXP (OID, IOID, STATUS) Values (1, 102, 'CANCELLED');
Insert into TEST_EXP (OID, IOID, STATUS) Values (2, 103, 'NEW');
Insert into TEST_EXP (OID, IOID, STATUS) Values (3, 104, 'DISCO');
Insert into TEST_EXP (OID, IOID, STATUS) Values (4, 105, 'DISCO');
Insert into TEST_EXP (OID, IOID, STATUS) Values (4, 106, 'NEW');
Insert into TEST_EXP (OID, IOID, STATUS) Values (5, 107, 'NEW');
Insert into TEST_EXP (OID, IOID, STATUS) Values (5, 108, 'CANCELLED');
[code]...

Now my problem is we should fetch the data based on the below rules

If an OID contains 2 IOIDs for which there is a NEW and DISCO status attached, then fetch the 2 records
If an OID has only 1 of these status, then ignore the same
If an OID has none of the 2 status, then ignore the same.

The expected output will be like below:

OID|IOID|STATUS
1 |100 |NEW
1 |101 |DISCO
4 |105 |DISCO
4 |106 |NEW

View 4 Replies View Related

SQL & PL/SQL :: Query On V$session - Status Column

Dec 2, 2011

If a session runs a query, the status will be inactive after completing the database call. I know this concept. But I just want to know what will be session status, if it running a procedure contains many select queries, DML quries and loop? Whether it will be active until procedure completes or it will be switching active and inactive?

View 3 Replies View Related

Forms :: Want To Check For Checkbox Status With One More Corresponding Value

Aug 3, 2011

I was working with forms and found a problem related to accessing of status of checkbox. In a block with multi record to be checked, if we want to check all the checkbox status which is already clicked, Then what should i do.

Now i am using the function Checkbox_check as:

if Checkbox_Checked('FVA.STATUS')

But the problem with this function, it is giving status of last clicked checkbox only.

View 17 Replies View Related

RAC & Failsafe :: RMAN Backup Status?

Oct 14, 2012

How to verify if the backups are successfully completed in RAC environment ?

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved