Catch the range of Date values
Hi, guys.I need to check the date range that my product was available. You can use as a basis the values in the table below, but this structure can be modified to add all the things that could support the solution:
ID_PRDCT DT_STRT DT_END
1 20/01/25 12/01/12
1 01/23/12-27/01/12
1 26/01/30 12/01/12
1 28/01/12-21/04/12
1 20/04/12-25/05/12
1 24/05/12-28/05/12
1 26/05/12 05/29/12
1 01/07/12-03/08/12
1 01/08/12-16/08/12
1 18/08/12-30/08/12
1 01/12/12-31/12/12
In this case, the result of my date range should be:
1 20/01/12-29/05/12
1 01/07/12-16/08/12
1 18/08/12-30/08/12
1 01/12/12-31/12/12
Hello
An the Heres how:
WITH got_new_grp AS
(
SELECT id_prdct, dt_strt, dt_end
, CASE
WHEN dt_strt <= MAX (dt_end)
OVER ( PARTITION BY id_prdct
ORDER BY dt_strt
ROWS BETWEEN UNBOUNDED PRECEDING
AND 1 PRECEDING
)
THEN 0
ELSE 1
END AS new_grp
FROM t
)
, got_grp AS
(
SELECT id_prdct, dt_strt, dt_end
, SUM (new_grp) OVER ( PARTITION BY id_prdct
ORDER BY dt_strt
) AS grp
FROM got_new_grp
)
SELECT id_prdct
, MIN (dt_strt) AS grp_dt_strt
, MAX (dt_end) AS grp_dt_end
FROM got_grp
GROUP BY id_prdct
, grp
ORDER BY id_prdct
, grp
;
This assumes dt_strt<= dt_end="" on="" every="">=>
If you would care to post CREATE TABLE and INSERT statements for your sample data, then I could test it.
You cannot use LAG or LEAD to see where each new group starts, because the order of the dt_strt is not the same as the order of the dt_end. In other words, if you ORDER BY dt_strt, two adjacent lines could be in the same group regardless of their values, because a previous line can have a dt_end, and as a result this line would be overlapp both of them. Similarly, if you ORDER BY dt_end, no matter what two adjacent lines contain, whether they are in the same group if som rank later has a sufficient dt_strt in advance.
Tags: Database
Similar Questions
-
SQL query to get the range of Date values
Hello
The database is Oracle11i.
I'm looking for a way to generate a list of the dates of a fixed date in the past (could be hardcoded) at the time of the day (sysdate).
In other words, if the fixed date is June 19, 2011, and assuming today ' today is June 24, 2011 the SQL must be able to generate the
Next: -.
June 19, 2011
June 20, 2011
June 21, 2011
June 22, 2011
June 23, 2011
June 24, 2011
And the constraint is that I can not make any change to the database in question. I can only shoot a (SELECT) SQL query. NO.
use time dimension type of approach (time dimension is not available here) and no procedure, etc. from PL/SQL. Is it possible?
Thank youJaimeen Shah wrote:
HelloThe database is Oracle11i.
I'm looking for a way to generate a list of the dates of a fixed date in the past (could be hardcoded) at the time of the day (sysdate).
In other words, if the fixed date is June 19, 2011, and assuming today ' today is June 24, 2011 the SQL must be able to generate the
Next: -.
June 19, 2011
June 20, 2011
June 21, 2011
June 22, 2011
June 23, 2011
June 24, 2011And the constraint is that I can not make any change to the database in question. I can only shoot a (SELECT) SQL query. NO.
use time dimension type of approach (time dimension is not available here) and no procedure, etc. from PL/SQL. Is it possible?
Thank you
SQL> def date_start = '13/11/2010' SQL> def date_end = '22/11/2010' SQL> with 2 data as ( 3 select to_date('&date_start', 'DD/MM/YYYY') date1, 4 to_date('&date_end', 'DD/MM/YYYY') date2 5 from dual 6 ) 7 select to_char(date1+level-1, 'DD/MM/YYYY') the_date 8 from data 9 connect by level <= date2-date1+1 10 / THE_DATE ---------- 13/11/2010 14/11/2010 15/11/2010 16/11/2010 17/11/2010 18/11/2010 19/11/2010 20/11/2010 21/11/2010 22/11/2010
-
Filter for table data, the range of data obtained and defined 2D
I produce data of an ultrasonic sensor at 1 K Hz, and there is a lot of data (data points range of 0 to 10). However, in some cases when I know that the data should be about 7 (for example) I get outliers (about 9 and 10). Is it possible to define a filter for data in the defined range.
I averaged the data to get an average value, and outliers are distorting. In the worst case, my outliers are 30 to 40% of the data generated. I created a filter to sort the data and, taken from the lowest value. I stop the loop when data reaches a value greater then 9. But this seems to take a long time (because the loop checks for each data point and there are 1000s of them).
Is there a better way to filter data and define a predefined table range to collect?
I enclose my filter.vi... and a set of samples of my previous data. The ranges of data of 10-8 and would like to have the range 7.5 to 8.5 to consider. The sensor records tension here and the problem can be solved by installing a different type of sensor, but if a filter in LabView can due it, the sensor that we use now is absolute.
I am in kind of emergency, my design in unfinished because of this problem, if someone can find some time to share some suggestions, I will be grateful.
Thanks in advance.
See attachment. I have incorporated the data you've posted in the vi. It doesn't seem like any data were less than 8.7 or so, so I modified the scope so it would be a few points on average. Some games were completely out of reach while the average came back like NaN (not a number) due to a division by zero.
-
How to define the range of data to a strict typdef through the control reference
Hello world
I'm trying to define the range of data to a strict typdef through the reference of the order, when I do, I get an 'error of property node.
Is it possible to set the range of the strict typdef.
Thank you
Vignesh
Vignesh1987 wrote:
I'm trying to define the range of data to a strict typdef through the reference of the order, when I do, I get an 'error of property node.
Is it possible to set the range of the strict typdef.
Try to set the original control (type-def) and not its instances... to open the reference of the original type-def command, use 'Open VI reference'.
Published:
These properties are not available with STRICT TYPE DEF.
a. data entry limits: increment property
-
Search a directory of data and display the data that is within the range of dates
Hello
I have a full idrectory of data from overtime, and I think of search in the directory and display the data files for specific dates. I only started this encoding yet but I figure I'll take the brain of some SMEs here labview and start in the right direction. My goal is to go through a comprehensive directory of data taken for a month or MORE csv files and select the data to process and display office files the date of its registration. If I take the data of last week, last month or last minute, it should just treat as an exact or more.
Please help me get started on the right foot
End date will be probably greater than the start date, right? So, end date must connect at the entrance to the upper limit. Then wire in the range? to the conditional terminal of a tunnel of conditional indexation.
Lynn
-
At least a record exists in details that cover the range of dates
Oracle version:
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
Hi gurus
I'm stuck with a scenario and your employees need help to solve this problem.
I have the following table:
Insertion and table creation
drop table ident;
create table ident
(
agreement_id number (5),
ident_pk number (5),
Date of Cov_effective_date,
Date of Cov_termination_date
);
-------------------
Insert ident
(
Select 100,1,to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-31','YYYY-MM-DD')
Union of all the
Select 200,2,to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-12-31','YYYY-MM-DD')
Union of all the
Select 300,3, to_date ('2013-03-01 ',' YYYY-MM-DD '), double null
);
Query on table
Select * ident;
Agreement_id ident_pk Cov_effective_date Cov_termination_date
100 1 13/01/01 13/01/31 200 2 13/01/01 13/12/31 300 3 13/03/01 ------------------------
Drop table ident_dtl;
create the table ident_dtl
(
ident_pk number (5),
ident_dtl_pk number (5),
date of effective_date,
date of termination_date
);
---------------------------------
insert into ident_dtl
(
Select 1-ident_pk, 10 ident_dtl_pk, to_date('2013-01-01','YYYY-MM-DD') effective_date, to_date('2013-01-31','YYYY-MM-DD') termination_date of double - to agreement_id = 100
Union of all the
Select 1,11,to_date('2013-01-01','YYYY-MM-DD'), to_date('2013-01-30','YYYY-MM-DD') of double - to agreement_id = 100
Union of all the
Select 2,12,to_date('2013-01-01','YYYY-MM-DD'), to_date('2013-01-30','YYYY-MM-DD') of double - for agreement_id = 200
Union of all the
Select 2.13, to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-15','YYYY-MM-DD') - for agreement_id is 200
Union of all the
Select 3.14, to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-15','YYYY-MM-DD') - for agreement_id = 300
Union of all the
Select 3.15, to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-15','YYYY-MM-DD') - for agreement_id = 300
);
Query on table
Ident_pk Ident_dtl_pk Effective_date Termination_date
1 10 13/01/01 13/01/31 1 11 13/01/01 13/01/30 2 12 13/01/01 13/01/30 2 13 13/01/01 13/01/15 3 14 13/01/01 13/01/15 3 15 13/01/01 13/01/15 Result of the will
Agreement_Id Ident_pk
200 2
300 3
------------------------------------
There is a single entry in ident against agreement_id and Ident_pk and if you can see that ident_pk is also present in the child table. My requirement is that at least 1 effective_date and child termination_date table must be match/equal to the parent table that is ident cov_effective_date and cov_termination_date against the same column of Ident_pk.
for example:
See the data in Ident_pk = 1, a = cov_effective_date 13/01/01 and its cov_termination_date = 13/01/31 and in the details table against column Ident_pk = 1, you can find that at lease 1 combinaisondes date match against Ident_pk = 1
If you see Ident_pk = 2, then you can't find all the effective_date and termination_date against its corresponding cov_effective_date and termination_date Ident_pk...
Same as 3
-----------
Summary is that there are date range in the ident against agreement_id and Ident_pk table and at least a range of dates even should be exist in detail table is ident_dtl against Ident_pk and if not then show that agreement_id and Ident_pk .
I made this task using PL/SQL, but I think that there is a way to do the same task in SQL. Guide and if you have any questions then please let me know. Thank you
Concerning
Shu
Hello
To be considered as a football game, the same line in ident_dtl must have effective_date and termination_date correspondence?
If so, a solution is:
SELECT i.agreement_id
i.ident_pk
Ident I have
LEFT OUTER JOIN ident_dtl d.ident_pk d = i.ident_pk
AND d.effective_date = i.cov_effective_date
AND d.termination_date = i.cov_termination_date
WHERE d.ident_pk IS NULL
;
Another pure SQL approach to such problems is to use an EXISTS subquery.
-
HSlider as the range of dates in the charts
IM using hslider as a date range to view database
on the dates selected for the chart.
My problem is how to change the chart data, based on the selection of the date of the hslider
Note: there are 3 sets of line in the table, so the data set should be based on the range of the hslider date selection
Any idea! Examplesfound a use for good double cursor if you try to do something like google, thank you cards to brendan, good job.
http://www.stretchmedia.ca/code_examples/chart_range_selection/main.html -
SQL help on records in the range of dates in a month
Hello
I have a simple requirement on Sql.
I have two records in the table of the absence-
Absence1 January 6, 2015 at 10 January 2015, 5 days
Absecne2 January 21, 2015 to 31 January 2015, 11 days
I need to write a Sql to get all the records separate date, as under-
January 5, 2015, 1 January 2015 days 5 days
January 6, 2015 at 10 January 2015 5 days of absence
January 20, 2015, 11 January 2015 10 days working days
January 21, 2015 to 31 January 2015, 11 days of absence
Could be for any month, I just have absences stored in a table and will pass the dates of beginning and end of the month.
I can write this in Pl/Sql, but wanted to see if it's possible in Sql.
TIA
Vignesh
Here's a way to do it.
with the days as
(select mstart + lv mdate
Of
(select mstart to_date('201501','yyyymm')-1, lv)
of the double
cross join
(select level lv
of the double
connect by level<=>=>
)
)
)
abs as
(select 1 anum, to_date ('20150106', 'YYYYMMDD') date_from, to_date ('20150110', 'YYYYMMDD') date_to, 5 days_abs of all double union)
Select option 2, 5 days_abs of the double to_date ('20150121', 'YYYYMMDD') from_date, to_date ('20150131', 'YYYYMMDD')
)
--
Select min (mdate) date_from, max (mdate) date_to, max (day_type) day_type
Of
(select mdate, where anum is null then 'working days' else 'Absence' end day_type, max (rn) on rn (order by mdate))
Of
(select mdate, anum, case when row_number() over (order by mdate) = 1 or nvl(anum,0) <> (nvl(anum,0)) (order of mdate) lag then row_number() (any order by mdate) end rn)
Of
(select mdate, anum)
days d
join left abs one on d.mdate between a.date_from and a.date_to
)
)
)
Group by rn
date_from order;
-
Catch the live ORA-01438 / value larger than specified precision allowed for
I have an another question! Is it possible to intercept the error ORA-01438 immediately before that the user sends data?
I have a db column that is used to store numbers of length 3.0. When you enter the 4 digits, the ORA-01438 is triggered.
The Apexlib does not work, since I have some conditional regions on the page in question.
Thanks for posting your thoughts and advice.
Kind regards
SEBSEB,
Simply create a validation and check the length of user input.
brgds,
Peter-----
Blog: http://www.oracle-and-apex.com
ApexLib: http://apexlib.oracleapex.info
Work: http://www.click-click.at
Training: http://www.click-click.at/apex-4-0-workshops -
Change of automatic color fields for the range of different values?
Hi, I am a new user of Acrobat Pro and I am trying to understand if it is possible to have the color of the field changed when the calculated value is within a specific range. I have a box of calculated field, and I want it turns to yellow when it reaches a specific numeric range and red when it gets to the other. A change in font color would work too...
The correct code might be:
(function() {}
var v = + event.value;
If (v< 16)="">
event.target.fillColor = color.green;
return;
}
If (v< 27)="">
event.target.fillColor = color.yellow;
return;
}
Value is greater than 27
event.target.fillColor = color.red;
})();
In particular this line of code is invalid:
If (27 16
) {} Something like this would be:
If (v > = 16 & v)< 27)="">
that translated to English is: If the value of the variable v is greater than or equal to 16 and less than 27...
So another functionally equivalent script could be:
var v = + event.value;
If (v< 16)="">
event.target.fillColor = color.green;
} else if (v > = 16 & v)< 27)="">
event.target.fillColor = color.yellow;
} else {/ / value is greater than or equal to 27}
event.target.fillColor = color.red;
}
I don't know if it's exactly what you want, but you should be able to revise it accordingly.
-
With the help of data values for the selection of members
Hello everyone:
I know there are operating functions, with members, strings, names of members... so that you are able to convert a string to a member (@MEMBER) and vice versa.
But, is it possible to use a value of Member to select someone else?. For example, if in the account dimension, I'm a member of 'parent' with value '100'. Could I put a value, using the value '100' in the '100' member registered in 'parent' to select this member. So if its value is '200', I should put in '200' member.
Thank you
Kind regards
JavierHello
First, you insert the CDF, essbase server. in the zip file, you have a small description how draconian make zip archive contains a file bat with a script maxl who do all the work. then restart the essbase server and then a new list of functions should be available on the script calc under Group Editor "functions only the user".
Here is a small piece of code I created for my current project.
This store a substring product code number on the cube
"Produccion_pan"->"Prod_CC_4"->"Referencia"=@JgetDoubleFromString(@SUBSTRING(@NAME(@CURRMBR("CompCosto")),6));
then I read that number and use it again as a member of another Sun name
"Produccion_pan"->"USD"="Produccion_pan"->"USD" + "Prod_CC_5"->"M3"*"Disponible"->"Total_Puesto"->@MEMBER(@CONCATENATE("PP_",@JgetStringFromDouble(codigo_p,@_false,@_false)))->"Coeficiente_v";
I hope it helps you. concerning
-
What is the range of values of type of data accepted by prepareBulk file?
In the Oracle documentation under "bulk 7.12 load graphics Using RDF Semantic support for Apache Jena", I see the code example for perpareBulk. The third parameter is documented as "type of data file: can be RDF/XML, N-TRIPLE, etc.". I found a code example that uses "TTL." as a value as well. It seems that "TTL" is accepted but not documented. What is the range of accepted values for the type parameter of data to prepareBulk file?
Hello
You can use the triple data serialization format following as string values:
"RDF/XML", "N-TRIPLE", "TURTLE" (or "TTL") and "N3". "RDF/XML-ABBREV" is a synonym for "RDF/XML".
For the quads, you can use either "N-QUADS" or "TRIG".
Thank you
Zhe Wu
-
Using 'New data value reference' in a loop
Hi all
I just read on the data value references (DVR?) and I'm trying to use them with overall functional (see table).
I don't think that I'm just doing. The final goal is a producer/consumer nickname. My concern is that I don't feel the implementation of the new primitive data value reference and re-stuffing the result in the FGV, should occur in each loop.
Of course I could "spread" data with a single gueue element (where the queue of new data would take place each loop). I just thought that I would play with them.
Beavercreek wrote:
I think that we defend the same point, but I can't seem to understand why this does not work the way I expected. I discovered the DVR (and queues) as a pointer, simply a way that the other vi can know where the data is located. The data that we are after is here. So, why Ch1 does not work in the data_reader.vi?
If we can get Ch1 to work data_reader without re-creating and re-writing of the reference in the FGV each pole (what does Ch2), we find no more what is wrong with my vI or I'm going to learn something that is still beyond me. I hope to hit me in the head this afternoon still
You are missing a fundamental idea: the function you call creates a reference that points to a specific value. To actually interact with this value (read/write), you need to use the structure of the International preliminary examination. At this time what you are creating a single reference for ch1 (which do you nothing with) and creation of multiple references to ch2 (where at each iteration that you replace the reference in the FGV, so you basically lose the old reference), so instead of having two DVRs, you really N + 1 DVR (where N is the number of iterations of the loop runs).
For your code works the way you want, you only need to create two digital video recorders (probably before the loop), then bring them inside the loop and use the structure of the International preliminary examination with nodes in R/W DVR to set the value in the DVR.
For example:
Other problems with the code, but this deal the DVR issue.
-
Over the range on USB-6008?
Dear jury,
I wonder if an alternating signal operating at the limit of the range selected on the 6008 have on beach? Is the limit of the range a dc value; or is it over the range capabliliy built in AC RMS measures? The manual is not clear on this. Someone at - he delt with it?
Thank you very much!
Mike
Mike,
the 6008 is not a method of coupling of special entry. Therefore, the given maximum scope is a DC value.
So if you select 5V as maximum range and have a sinusoidal signal with Vp = 2V and 4V offset, you will cut the positiv to 5V wave.
hope this helps,
Norbert
-
I have the following query, which works without problem. This will expand the range of dates, proof of identity, in a list of dates for me:
How can I do this for more than 1 sheet well? for exampleSELECT j_id , date_1 + LEVEL - 1 datum FROM (SELECT 123 j_id, TO_DATE('01/01/2012', 'DD/MM/YYYY') date_1, TO_DATE('31/01/2012', 'DD/MM/YYYY') date_2 FROM DUAL) CONNECT BY LEVEL <= ( date_2 - date_1 + 1);
Thank you.SELECT j_id , date_1 + LEVEL - 1 datum FROM (SELECT 123 j_id, TO_DATE('01/01/2012', 'DD/MM/YYYY') date_1, TO_DATE('31/01/2012', 'DD/MM/YYYY') date_2 FROM DUAL UNION SELECT 456 j_id, TO_DATE('01/02/2012', 'DD/MM/YYYY') date_1, TO_DATE('29/02/2012', 'DD/MM/YYYY') date_2 FROM DUAL) CONNECT BY LEVEL <= ( date_2 - date_1 + 1);
Hello
Here's one way:
WITH cntr AS ( SELECT LEVEL - 1 AS n FROM ( SELECT MAX (date_2 - date_1) AS max_dif FROM table_x ) CONNECT BY LEVEL <= 1 + max_dif ) SELECT x.j_id , x.date_1 + c.n FROM table_x x JOIN cntr c ON c.n <= x.date_2 - x.date_1 ORDER BY x.j_id , c.n ;
If you do any filtering, it may be more effective to do this first. Start the WITH clause with a subquery that performs filtering, then use this result placed instead of your full table in the view online within the cntr as well as in the main query.
For example:CREATE TABLE table_x AS SELECT 123 j_id, TO_DATE('01/01/2012', 'DD/MM/YYYY') date_1, TO_DATE('31/01/2012', 'DD/MM/YYYY') date_2 FROM DUAL UNION SELECT 456 j_id, TO_DATE('01/02/2012', 'DD/MM/YYYY') date_1, TO_DATE('29/02/2012', 'DD/MM/YYYY') date_2 FROM DUAL UNION SELECT 999, TO_DATE ('01/01/2013', 'DD/MM/YYYY'), TO_DATE ('31/12/2013', 'DD/MM/YYYY') FROM dual ; WITH filtered_data AS ( SELECT * FROM table_x WHERE date_1 < TO_DATE ('01/07/2012', 'DD/MM/YYYY') ) , cntr AS ( SELECT LEVEL - 1 AS n FROM ( SELECT MAX (date_2 - date_1) AS max_dif FROM filtered_data ) CONNECT BY LEVEL <= 1 + max_dif ) SELECT f.j_id , f.date_1 + c.n FROM filtered_data f JOIN cntr c ON c.n <= f.date_2 - f.date_1 ORDER BY f.j_id , c.n ;
Published by: Frank Kulash, 27 January 2012 10:10
Posted filtering example
Maybe you are looking for
-
Hello guys.I have a bmp to png converter. I need parallel to it.COS I need to convert 50 photos in a little time as possible.This my VI, does not work with parallel. COS icons are locked and etc.Have u any idea, how to proceed?
-
Windows Server 2012 does not seem to recognize the space between the program and files
I installed 'R' in D:\Program Files.Then I need to install another application that must refer to this path and validate during its installation. Installation of the next application saying that there is a "Invalid Version of R. If I install R in the
-
unknown error when using vi express daq devices
Hi there I have unknown error when you try to use express DAQ of VI. I downloaded and installed device drivers OR who needed to generate EXE since then this problem was occurring what should I do I've done everything that has been mentioned in the fo
-
original title: WiFi I want to connect to a wireless network on my laptop. When I go to the page of networks wirelss under the "choose a wireless network" it says "Windows cannot configure this wireless connection. If you want Windows to configure th
-
Error: 0 x 80004002 then tried to delete the files
Original title: 0x80004002__ Some Web sites have spared themselves links as files on my computer and I can't delete them. I typed in this error code it gave me (0 x 80004002) and dd everything that he told me to do, but I can remove them yet. What sh