Select multiple date ranges?
I am looking to select from a set of date ranges. I know that a UNION will work, but how to I get a valid set of results from multiple dates without a UNION?
example:
select date from test
where date >= '01-MAR-07 0000'
and date <= '02-MAR-07 0000'
and date >= '04-MAR-07 0000'
and date <= '08-MAR-07 0000'
order by date;
This gets zero records.
But if I use UNION:
select date from test
where date >= '01-MAR-07 0000'
and date <= '02-MAR-07 0000'
union
select datre from test
and date >= '04-MAR-07 0000'
and date <= '08-MAR-07 0000'
order by date;
It works, I get the records in no test table.
How can I structure this query to work without UNION?
true, date is taken eh?
I am still running into an issue:
Let's say I am using the following context:
select date1, name from test
where name in ('SUNDAR', 'ASUNDAR')
and date1 >= '01-MAR-07 0000'
and date1 <= '03-MAR-07 0000'
or (date1 >= '05-MAR-07 0000'
and date1 <= 07-MAR-07 0000');
My results are wrong, it would not include the select as part of the or clause.
Similar Messages
-
How to display null values in the graphs, when i select a date range?
Hi,
Can you please help me in achieving the below requirement:
We have a date promt, i have selected the date range from 12-Oct-2009 to 15-Oct-2009 and clicked on the go button.
In the above date range, data is only availabe on 14-Oct-2009. here the requirement is to display as all the records (12th, 13th , 14th & 15th) in the bar graph.
Currently the graph view is displaying the data only for 14-Oct-2009 in the bar graph.
If data is not available it should display in the bar graph as empty for that particular dates.
Help is highly apprieciated.
Thanks in Advance.Check out [this post|http://obiee101.blogspot.com/2009/04/obiee-showing-zero-in-bargraph.html].
-
XL Reporter - Selection of date range for report templates
Dear All,
I want to create a report using XL reporter and attach it to the main SAP B1 reports module . For this I have created the template using report composer .
Issue:
I have only one sub-period (ie,year wise in the posting periods)
how i can select the date range in the Composer and attach it to the main menu.
Regards,
Suresh Kannan.P.Suresh,
1. Goto Report Designer
2. there u can find "Advanced Report Builder" on left side of the window
3. At the below u can find three buttons like "Parameters", "Properties","Apply"
4. Click on "Parameters"
5. then Parameters window will populate
6. Click the new Button
7. Name: give as u like
Category: Literal
Type: Date
Attribute: Leave blank
Default Vale: Leave Blank
Prompt: From Date
This is the process to create the parameters.
create two parameters. one is fdate and ldate. -
How to select multiple data without select options?
Dear experts,
I have a rquirement that i have a one selection screen and in that selection screen on date field is there which is parameter type. we using this parameter date field in the program for selecting data..after that i am using the logic to multiple value..now my requirement is how to select the data for multiple value..
PARAMETERS : SO_DATE TYPE SY-DATUM OBLIGATORY.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
DATE = so_date
DAYS = 1
MONTHS = 0
SIGNUM = '-'
YEARS = 0
IMPORTING
CALC_DATE = so_date
l_cm_first+0(6) = so_date+0(6). " month & year
l_cm_first+6(2) = '01'. " date
l_cm_end = so_date.
my requirement is that how to use l_cm_first and l_cm_end multiple selection in select query ??
eg- i want to fetch the data from 1/8/2014 to 11/08/2014 using this field l_cm_first and l_cm_endl_cm_first+0(6) = so_date+0(6). " month & year
l_cm_first+6(2) = '01'. " date
l_cm_end = so_date.
after executing this line l_cm_first = 1/8/2014 and l_cm_end = 11/08/2014
now i have to select in this range how to do it? -
Select multiple date with interval in date-navigator
Hi,
Is it possible to have a multiple date selection with interval in a date-navigator. When yes, how?
Richard MiddelburgLook at the below thread:
Re: Date Navigator Challenge
Raja T -
Adf Calendar multiple date range disabled.
Hi,
I have a requirement where I have few date ranges say 1st -5th march, 9th-11th march.. and while opening date calendar these date ranges should be disabled (blacked out ) . MinValue and maxValue attribute is only for single date range. I need for multiple date rangesNo version number, no clear idea of what you mean by "adf Calendar"
If you are talking about [url http://docs.oracle.com/cd/E16162_01/apirefs.1112/e17491/tagdoc/af_inputDate.html]af:inputDate, look at the disabledDays property
John -
Querying multiple date ranges in one select
Hello guys,
DDL:
CREATE TABLE DBO.SALES (
TYPE VARCHAR(50)
, REVENUE DECIMAL(19,2)
, SALE_DATE_TIME DATETIME)
What I'm trying to figure out is how I can pass two dates to a where clause querying this table, a start date and an end date. From this I can group up the REVENUE for each TYPE (but there's more):
SELECT TYPE, COUNT(*) AS NBR_OF_SALES, SUM(REVENUE) AS TOTAL_REVENUE
FROM REPORTS.DBO.SALES
WHERE SALE_DATE_TIME BETWEEN @STARTPERIOD AND @ENDPERIOD
GROUP BY TYPE
I'd now like to add a couple of extra columns in the select that calculates the TOTAL_REVENUE equal to the time period of the two dates, but offset by 1 week, 1 month and 1 year, so that would be three columns. I'm guessing this would be possible with a
CROSS APPLY, but I just can't get my head around it at this time. Just for clarity, the expected output would contain these columns:
TYPE, NBR_OF_SALES, TOTAL_REVENUE, TOTAL_REVENUE_LAST_WEEK, TOTAL_REVENUE_LAST_MONTH, TOTAL_REVENUE_LAST_YEAR
Any help is greatly appreciated.SELECT TYPE,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN @STARTPERIOD AND @ENDPERIOD THEN 1 ELSE 0 END) AS NBR_OF_SALES,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(WEEK,1,@STARTPERIOD) AND DATEADD(WEEK,1,@ENDPERIOD) THEN 1 ELSE 0 END) AS NBR_OF_SALES_WeekOffset,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(MONTH,1,@STARTPERIOD) AND DATEADD(MONTH,1,@ENDPERIOD) THEN 1 ELSE 0 END) AS NBR_OF_SALES_MonthOffset,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN @STARTPERIOD AND @ENDPERIOD THEN REVENUE ELSE 0 END) AS TOTAL_REVENUE,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(WEEK,1,@STARTPERIOD) AND DATEADD(WEEK,1,@ENDPERIOD) THEN REVENUE ELSE 0 END) AS TOTAL_REVENUE_WeekOffset,
SUM(CASE WHEN SALE_DATE_TIME BETWEEN DATEADD(MONTH,1,@STARTPERIOD) AND DATEADD(MONTH,1,@ENDPERIOD) THEN REVENUE ELSE 0 END) AS TOTAL_REVENUE_MonthOffset
FROM REPORTS.DBO.SALES
WHERE SALE_DATE_TIME BETWEEN @STARTPERIOD AND DATEADD(MONTH,1,@ENDPERIOD)
GROUP BY TYPE
Is this what you want?
We have three total columns per metric, one for the period, one for the period offset by a week, and one for the period offset by a month.
We've also adjusted the where so all the data for the offset period is included. -
Selecting missing date range with previous records value
Hello,
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SET DEFINE OFF;
create table t(NBR_OF_S number, NBR_OF_C number, S_DATE date);
Insert into T
(NBR_OF_S, NBR_OF_C, S_DATE)
Values
(34, 40, TO_DATE('05/01/2012 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into T
(NBR_OF_S, NBR_OF_C, S_DATE)
Values
(27, 29, TO_DATE('03/01/2012 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into T
(NBR_OF_S, NBR_OF_C, S_DATE)
Values
(21, 23, TO_DATE('12/01/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into T
(NBR_OF_S, NBR_OF_C, S_DATE)
Values
(19, 20, TO_DATE('10/01/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into T
(NBR_OF_S, NBR_OF_C, S_DATE)
Values
(18, 19, TO_DATE('09/01/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into T
(NBR_OF_S, NBR_OF_C, S_DATE)
Values
(17, 17, TO_DATE('08/01/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into T
(NBR_OF_S, NBR_OF_C, S_DATE)
Values
(16, 16, TO_DATE('06/01/2011 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into T
(NBR_OF_S, NBR_OF_C, S_DATE)
Values
(9, 9, TO_DATE('12/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into T
(NBR_OF_S, NBR_OF_C, S_DATE)
Values
(5, 5, TO_DATE('11/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
Insert into T
(NBR_OF_S, NBR_OF_C, S_DATE)
Values
(2, 2, TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
COMMIT;
SQL> select * from t order by 3 desc;
NBR_OF_S NBR_OF_C S_DATE
34 40 01-MAY-12
27 29 01-MAR-12
21 23 01-DEC-11
19 20 01-OCT-11
18 19 01-SEP-11
17 17 01-AUG-11
16 16 01-JUN-11
9 9 01-DEC-10
5 5 01-NOV-10
2 2 01-JAN-10
10 rows selected.I want the output like as follows, all those missing date i need to carry on the last one's number
NBR_OF_S NBR_OF_C S_DATE
34 40 01-MAY-12
27 29 01-APR-12
27 29 01-MAR-12
21 23 01-FEB-12
21 23 01-JAN-12
21 23 01-DEC-11
19 20 01-NOV-11
19 20 01-OCT-11
18 19 01-SEP-11
17 17 01-AUG-11
16 16 01-JUL-11
16 16 01-JUN-11
9 9 01-MAY-11
9 9 01-APR-11
9 9 01-MAR-11
9 9 01-FEB-11
9 9 01-JAN-11
9 9 01-DEC-10
5 5 01-NOV-10
2 2 01-OCT-10
2 2 01-SEP-10
2 2 01-AUG-10
2 2 01-JUL-10
2 2 01-JUN-10
2 2 01-MAY-10
2 2 01-APR-10
2 2 01-MAR-10
2 2 01-FEB-10
2 2 01-JAN-10Any help would be greatly appreciate.
Note: The date value I have created for this sample is monthly, based on the condition the data value I may need to generate weekly also. That's Monthly or weekly either one
Thanks,And what is AMT? You didn't provide such column in your original post. Anyway, MODEL solution based on original post:
select nbr_of_s,
nbr_of_c,
s_date
from t
model
partition by(rowid)
dimension by(1 d)
measures(
nbr_of_s,
nbr_of_c,
s_date,
months_between(lag(s_date) over(order by s_date desc),s_date) cnt
rules(
nbr_of_s[for d from 1 to cnt[1] increment 1] = nbr_of_s[1],
nbr_of_c[for d from 1 to cnt[1] increment 1] = nbr_of_c[1],
s_date[for d from 1 to cnt[1] increment 1] = add_months(s_date[1],cv(d) - 1)
order by s_date desc
NBR_OF_S NBR_OF_C S_DATE
34 40 01-MAY-12
27 29 01-APR-12
27 29 01-MAR-12
21 23 01-FEB-12
21 23 01-JAN-12
21 23 01-DEC-11
19 20 01-NOV-11
19 20 01-OCT-11
NBR_OF_S NBR_OF_C S_DATE
18 19 01-SEP-11
17 17 01-AUG-11
16 16 01-JUL-11
16 16 01-JUN-11
9 9 01-MAY-11
9 9 01-APR-11
9 9 01-MAR-11
9 9 01-FEB-11
NBR_OF_S NBR_OF_C S_DATE
9 9 01-JAN-11
9 9 01-DEC-10
5 5 01-NOV-10
2 2 01-OCT-10
2 2 01-SEP-10
2 2 01-AUG-10
2 2 01-JUL-10
2 2 01-JUN-10
NBR_OF_S NBR_OF_C S_DATE
2 2 01-MAY-10
2 2 01-APR-10
2 2 01-MAR-10
2 2 01-FEB-10
2 2 01-JAN-10
29 rows selected.
SQL> SY.
Edited by: Solomon Yakobson on Jun 11, 2012 1:34 PM -
Re: Selecting multiple dates that are outside a specified time period
Hi All,
I have the following dataset/table structure:
Order # Customer ID Order Date
4 10 14-Jan-09
3 10 25-Jul-08
2 10 20-Jul-08
1 10 15-Jul-08
What I'm trying to do is a tad complicated for my skillset. I want to be able to select a particular order date for each unique individual but I need to apply a rule that if each subsequent order date falls within 180 days of the previous order date, the date gets ignored until it reaches an order date that is more than 180 days so it captures that particular order along with the initial (minimum) order. So for the example above the first order date for Customer ID #10 is 15-jul-2008, each subsequent order (Order #'s 2 and 3) are within 180 days so they get ignored until Order #4 comes along which is exactly 183 days after the first order date so this goes beyond the 180 day time limit and the record needs to get included so I need a query that will essentially pull the following two records:
Order # Customer ID Order Date
1 10 15-Jul-08
4 10 14-Jan-09
Thanks,
EdThis works for your sample data
SQL> with sample_data as (
2 select 4 ord_no, 10 cust_no, to_date('14-Jan-2009', 'dd-mon-yyyy') dt
3 from dual union all
4 select 3, 10, to_date('25-Jul-2008', 'dd-mon-yyyy') from dual union all
5 select 2, 10, to_date('20-Jul-2008', 'dd-mon-yyyy') from dual union all
6 select 1, 10, to_date('15-Jul-2008', 'dd-mon-yyyy') from dual)
7 select sd.* from sample_data sd
8 join (select cust_no, min(dt) dt from sample_data
9 group by cust_no) mo
10 on sd.cust_no = mo.cust_no and
11 (sd.dt = mo.dt or
12 sd.dt >= mo.dt + 180);
ORD_NO CUST_NO DT
4 10 14-JAN-2009
1 10 15-JUL-2008This will also include all orders more than 180 days after the first order.
John -
Is it possible to select multiple dates from a calendar?
Hi All,
I am looking for a way of somehow selecting more than one date in the Apex calendar. What I am after is something like in Outlook you can select 5 days for one action.
Is something like that (or simmilar) is possible with Apex?
Regards,
Pawel.Boy, this is something we're struggling with too. So we'd like to hear others' ideas on this also.
thank you,
iggy -
How to display multiple data range by using variable?
Hi experts,
How do I set a variable at EPM add-in for Excel for dynamic display two year's data? just like as below:
***User will execute this report from BPC web(work list).
user input => 2006
Report display 2006 and 2007 data
user input => 2008
Report display 2008 and 2009 data
I know if we use BPC 7.5 we can config this by Excel formula, How do I set this function on EPM add-in 10.0?
best regards,
Evans.I think you can effectively do that using EPMOlapmember function...Just follow :-
2013.TOTAL <---- EPMContextMember(,"TIME","LEVEL = YEAR")
2012.TOTAL <---- EPMMemberOffset(,C2,-1)
2013.DEC <---- LEFT($C$2,4)&".DEC"
Similarly 2012.DEC <---- LEFT($D$3,4)&".DEC"
Projection & Actual are hard coded in Cell F2 and F3 respectively...
Then you keep the "ACTIVE MEMBER RECOGNITION" as ON...
Use the OLAP Member function ..as shown in the screen shot for all the 12 months.. -
Query with multiple date ranges
I want the suggesstions to rewrite the below query. Is there any better way to rewrite the query by avoiding union all. This table has over 500 million records and the indexes are already created.
select * from emp
where job='MANAGER' and hiredate between '10-MAR-2007' TO '11-APR-2008'
UNION ALL
select * from emp
where job='ANALYST' and hiredate between '20-MAR-2008' TO '16-FEB-2009';Hello Boochi,
try this,
SELECT EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, DEPTNO
FROM emp
WHERE (job = 'MANAGER' AND hiredate Between '10-MAR-2007' And '11-APR-2008') OR
(job = 'ANALYST' AND hiredate Between '20-MAR-2008' And '16-FEB-2009');please, dont use '*'
Regards,
Christian Balz
Edited by: Christian Balz on 01/04/2009 08:35 - Add Sugestion -
Multiple Date selection in ADF
Hi Friends,
I am using jdeveloper 10.1.3.3 for development of application.
I have requirement of Multiple Date selection in ADF using in built Date Components.
I have looked at af:selectinputdate and af:choosedate components for this requirement.. I found that we can choose only single date from these components. Is it possible to select more than one date from any of these two components. ??
Please help me in solving this..
thanks in advance..
Thanks,
Ravi.Hi Vervecken,
Please find my requriements below:
Do you want to select multiple individual dates? Is there a maximum number of dates to select?
Yes multiple Individual dates... No max number of dates selection.Do you want to select a "date range"? Do you want to select multiple "date ranges"?
date range i.e from and to is also fine.. but not multiple date range...Do you want to select multiple "data ranges" combined with multiple individual dates?
No.. Not required...Regards
Ravi -
Drop Down Box for Date Range Selection
I have multiple queries on the same worksheet with different variables for each. To simplify changing the one consistent variable, the date range, I have added a drop down box tied to all infoproviders in the query. This would work if I wanted to select a single date but I cannot determiine how to select a date range (01/2010 - 12/2010). Any ideas on how I might accomplish this? I am using Netweaver 7.1.
You can use two single-input variables: one for DATE FROM and the other for DATE TO and use them in query definition to restrict the date (restriction type: Range between DATE FROM and DATE TO).
Then you create two dropdown boxes, one for each variable.
Regards,
Dorota -
How to select Months with in a date range
Hi
I am working on a report which will list out Month wise totals in each row.
How should i select the Months with in a date range and do the sum ( User may select the date range for N number of years also. Example : 01/10/2000 to 01/01/2010 )
Thanks in advance
Thanks®ards
MrudulaHi
Use the following code:
data: l_date(8) value '03042007',
l_mname type t247-ktx,
l_c(25).
select single ktx from t247
into l_mname
where spras = sy-langu
and mnr = l_date+2(2).
concatenate l_mname l_date+6(2)
into l_c." SEPARATED BY space.
data: g_date(10) type c. " Processing date of Report
g_date = sy-datum.
concatenate g_date0(4) g_date4(2) g_date+6(2) into g_date.
data: g_date1(10) type c.
g_date1 = so_verab-high.
concatenate g_date10(4) g_date14(2) g_date1+6(2) into g_date1.
Regards,
Sreeram
Maybe you are looking for
-
Can SL restore from a Lion Time Machine backup?
I want to downgrade from Lion to SL. If I do a fresh install of SL will it be able to read my Lion Time Machine backup to restore my applications and data?
-
How do i get my imac off 10.4.11
my imac is stuck on os x 10.4.11 i just kinda need some direction on how to upgrade it from this to 10.5
-
Network Name Resource Availability - failover cluster error 1196 on Hyper-V 2012 R2 nodes
Hello, We're getting this error in our even logs of our four node failover cluster, we tried deleting Host A record in DNS management, that did nothing. Failover cluster event: 1196 "Cluster network name resource 'CAUCrgt8' failed registration of one
-
How to open acrobat in java and compare two files using javacode
I am absolutely new to use acrobat software in Java. I want to open two pdf files at a time and then compare the differences between them thru java program . i am not sure how to do it. iam trying many ways without success. I used jre and could open
-
Will InDesign accept equations set in MS Word using MathCAD and/or Mathematica?
will InDesign accept equations set in MS Word using MathCAD and/or Mathematica?