Date range iteration
I know add_month function
my requrement is to get two dates alternatively in a loop/iteration.
if have two dates fdt=5/18/2011 ; ndt=06/02/2011, if i give input as 7/20/2011 then I have to get nearest greter date by iterating these two date alternatively and the end result should be 08/02/2011
05/18/2011
06/02/2011
06/18/2011
07/02/2011
07/18/2011
08/02/2011
as 08/02/2011 is greter then 07/20/2011(input date) this we have to return.same way I have to navigate for lesser dates also like if I give 04/20/2011 as input I have to get 05/02/2011.
Thanks,
Hesh.
Hi,
Hope the below helps.
SQL> SELECT MIN(fdt) FROM (
2 SELECT ADD_MONTHS(to_date('18-May-2011'), level - 1) fdt
3 FROM dual
4 CONNECT BY LEVEL <= CEIL(GREATEST(MONTHS_BETWEEN('20-Jul-2011', '18-May-2011'), MONTHS_BETWEEN('20-Jul-2011','02-Jun-2011'))) + 1
5 UNION
6 SELECT ADD_MONTHS(to_date('02-Jun-2011'), level - 1) ndt
7 FROM dual
8 CONNECT BY LEVEL <= CEIL(GREATEST(MONTHS_BETWEEN('20-Jul-2011', '18-May-2011'), MONTHS_BETWEEN('20-Jul-2011','02-Jun-2011'))) + 1
9 )
10 WHERE fdt > '20-Jul-2011'
11 /
MIN(FDT)
02-Aug-2011
SQL>
SQL> SELECT MIN(fdt) FROM (
2 SELECT ADD_MONTHS(to_date('18-May-2011'), level - 1) fdt
3 FROM dual
4 CONNECT BY LEVEL <= CEIL(GREATEST(MONTHS_BETWEEN('05-May-2011', '18-May-2011'), MONTHS_BETWEEN('05-May-2011','02-Jun-2011'))) + 1
5 UNION
6 SELECT ADD_MONTHS(to_date('02-Jun-2011'), level - 1) ndt
7 FROM dual
8 CONNECT BY LEVEL <= CEIL(GREATEST(MONTHS_BETWEEN('05-May-2011', '18-May-2011'), MONTHS_BETWEEN('05-May-2011','02-Jun-2011'))) + 1
9 )
10 WHERE fdt > '05-May-2011'
11 /
MIN(FDT)
18-May-2011
SQL> Regards
Ameya
Similar Messages
-
I have a DATA table which consists of Minutely data. For every unique filename, solar_id, year, day there is a unique processing stage that can exist and to find the highest processing stage we select the MAX(date_stamp) for that particular day since it will be the latest touched stage.
So for any given day we can have 1440minutes x (5processing stages on average) = ~7k records.
If I have a query that wants to look at the highest processing stage that exists each day over a TIME FRAME, how can I improve it's performance?
SELECT DISTINCT s.NAME NAME, s.climate_id climate_id, a.solar_id solar_id,
a.processing_stage processing_stage, a.YEAR YEAR, a.DAY DAY,
TO_CHAR (a.date_stamp, 'YYYY-MM-DD HH24:MI:SS') date_stamp, a.user_id
FROM solar_station s, DATA a
WHERE a.solar_id = '636'
AND s.solar_id = '636'
AND s.climate_id = '611KBE0'
AND a.solar_id = s.solar_id
AND a.time_stamp BETWEEN TO_DATE ('2004-9-8', 'YYYY-MM-DD')
AND TO_DATE ('2004-9-20', 'YYYY-MM-DD')
AND (a.solar_id, a.filename, a.YEAR, a.DAY, a.date_stamp) IN (
SELECT b.solar_id, b.filename, b.YEAR, b.DAY, MAX (b.date_stamp)
FROM DATA b
WHERE b.solar_id = '636'
AND b.solar_id = s.solar_id
AND b.time_stamp BETWEEN TO_DATE ('2004-9-8', 'YYYY-MM-DD')
AND TO_DATE ('2004-9-20', 'YYYY-MM-DD')
GROUP BY b.solar_id, b.filename, b.YEAR, b.DAY)
ORDER BY s.NAME, a.YEAR, a.DAY;The data table is partioned by YEAR and sub-partioned by solar_id.Hmm, still a full table scan on data. This is
probably caused by the unnecessary line
AND b.solar_id = s.solar_idWhat happens if you remove this line?
Regards,
Rob.
SELECT DISTINCT s.NAME NAME, s.climate_id climate_id, a.solar_id solar_id,
a.processing_stage processing_stage, a.YEAR YEAR, a.DAY DAY,
TO_CHAR (a.date_stamp, 'YYYY-MM-DD HH24:MI:SS') date_stamp, a.user_id
FROM solar_station s, DATA a
WHERE a.solar_id = '636'
AND s.solar_id = '636'
AND s.climate_id = '611KBE0'
--AND a.solar_id = s.solar_id
and year between 2004 and 2004
AND a.time_stamp BETWEEN TO_DATE ('2004-9-8', 'YYYY-MM-DD')
AND TO_DATE ('2004-12-20', 'YYYY-MM-DD')
AND (a.solar_id, a.filename, a.YEAR, a.DAY, a.date_stamp) IN (
SELECT b.solar_id, b.filename, b.YEAR, b.DAY, MAX (b.date_stamp)
FROM DATA b
WHERE b.solar_id = '636'
--AND b.solar_id = s.solar_id
and year between 2004 and 2004
AND b.time_stamp BETWEEN TO_DATE ('2004-9-8', 'YYYY-MM-DD')
AND TO_DATE ('2004-12-20', 'YYYY-MM-DD')
GROUP BY b.solar_id, b.filename, b.YEAR, b.DAY)
ORDER BY s.NAME, a.YEAR, a.DAY;
PLAN_TABLE_OUTPUT
Plan hash value: 4121458178
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 156 | 19500 | 30539 (4)| 00:06:07 | | |
| 1 | SORT ORDER BY | | 156 | 19500 | 30539 (4)| 00:06:07 | | |
| 2 | HASH UNIQUE | | 156 | 19500 | 30538 (4)| 00:06:07 | | |
|* 3 | HASH JOIN | | 156 | 19500 | 30537 (4)| 00:06:07 | | |
| 4 | NESTED LOOPS | | 1401 | 95268 | 15279 (4)| 00:03:04 | | |
|* 5 | TABLE ACCESS BY INDEX ROWID| SOLAR_STATION | 1 | 27 | 1 (0)| 00:00:01 | | |
|* 6 | INDEX UNIQUE SCAN | SOLAR_STATION_PK | 1 | | 0 (0)| 00:00:01 | | |
| 7 | VIEW | VW_NSO_1 | 1401 | 57441 | 15278 (4)| 00:03:04 | | |
| 8 | SORT GROUP BY | | 1401 | 82659 | 15278 (4)| 00:03:04 | | |
| 9 | PARTITION RANGE ITERATOR | | 272K| 15M| 15245 (3)| 00:03:03 | 10 | 11 |
| 10 | PARTITION HASH SINGLE | | 272K| 15M| 15245 (3)| 00:03:03 | 1 | 1 |
|* 11 | TABLE ACCESS FULL | DATA | 272K| 15M| 15245 (3)| 00:03:03 | | |
| 12 | PARTITION RANGE ITERATOR | | 272K| 14M| 15254 (4)| 00:03:04 | 10 | 11 |
| 13 | PARTITION HASH SINGLE | | 272K| 14M| 15254 (4)| 00:03:04 | 1 | 1 |
|* 14 | TABLE ACCESS FULL | DATA | 272K| 14M| 15254 (4)| 00:03:04 | | |
Predicate Information (identified by operation id):
3 - access("A"."SOLAR_ID"="$nso_col_1" AND "A"."FILENAME"="$nso_col_2" AND "A"."YEAR"="$nso_col_3" AND
"A"."DAY"="$nso_col_4" AND "A"."DATE_STAMP"="$nso_col_5")
5 - filter("S"."CLIMATE_ID"='611KBE0')
6 - access("S"."SOLAR_ID"='636')
11 - filter("B"."TIME_STAMP">=TO_DATE('2004-09-08 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND "YEAR"=2004 AND
"B"."SOLAR_ID"='636' AND "B"."TIME_STAMP"<=TO_DATE('2004-12-20 00:00:00', 'yyyy-mm-dd hh24:mi:ss'))
14 - filter("A"."TIME_STAMP">=TO_DATE('2004-09-08 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND "YEAR"=2004 AND
"A"."SOLAR_ID"='636' AND "A"."TIME_STAMP"<=TO_DATE('2004-12-20 00:00:00', 'yyyy-mm-dd hh24:mi:ss'))>
Message was edited by:
Rob van Wijk
ddition questions:
What is the outcome of:
select count(*)
from ( SELECT s.NAME NAME
, s.climate_id climate_id
, a.solar_id solar_id
, a.processing_stage processing_stage
, a.YEAR YEAR
, a.DAY DAY
, TO_CHAR (a.date_stamp, 'YYYY-MM-DD HH24:MI:SS')
date_stamp
, a.user_id
, max(a.date_stamp) over (partition by a.solar_id,
a.file_name, a.year, a.day) max_date_stamp
FROM solar_station s
, DATA a
WHERE a.solar_id = '636'
AND s.solar_id = '636'
AND s.climate_id = '611KBE0'
AND a.solar_id = s.solar_id
AND year between 2004 and 2004
AND a.time_stamp BETWEEN TO_DATE ('2004-9-8',
'YYYY-MM-DD') AND TO_DATE ('2004-12-20',
'YYYY-MM-DD')
Here we get:
COUNT(*)
1266111
1 row selected.
You might remove the subquery by issuing:
select distinct *
from ( SELECT s.NAME NAME
, s.climate_id climate_id
, a.solar_id solar_id
, a.processing_stage processing_stage
, a.YEAR YEAR
, a.DAY DAY
, TO_CHAR (a.date_stamp, 'YYYY-MM-DD HH24:MI:SS')
date_stamp
, a.user_id
, max(a.date_stamp) over (partition by a.solar_id,
a.file_name, a.year, a.day) max_date_stamp
FROM solar_station s
, DATA a
WHERE a.solar_id = '636'
AND s.solar_id = '636'
AND s.climate_id = '611KBE0'
AND a.solar_id = s.solar_id
AND year between 2004 and 2004
AND a.time_stamp BETWEEN TO_DATE ('2004-9-8',
'YYYY-MM-DD') AND TO_DATE ('2004-12-20',
'YYYY-MM-DD')
date_stamp = max_date_stamp
ORDER BY s.NAME
, a.YEAR
, a.DAY
select distinct *
from ( SELECT s.NAME NAME
, s.climate_id climate_id
, a.solar_id solar_id
, a.processing_stage processing_stage
, a.YEAR YEAR
, a.DAY DAY
, TO_CHAR (a.date_stamp, 'YYYY-MM-DD HH24:MI:SS') date_stamp
, a.user_id
, max(a.date_stamp) over (partition by a.solar_id, a.filename, a.year, a.day) max_date_stamp
FROM solar_station s
, DATA a
WHERE a.solar_id = '636'
AND s.solar_id = '636'
AND s.climate_id = '611KBE0'
AND a.solar_id = s.solar_id
AND year between 2004 and 2004
AND a.time_stamp BETWEEN TO_DATE ('2004-9-8', 'YYYY-MM-DD') AND TO_DATE ('2004-12-20', 'YYYY-MM-DD')
where date_stamp = max_date_stamp
ORDER BY NAME
, YEAR
, DAY;
PLAN_TABLE_OUTPUT
Plan hash value: 3043498213
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 14702 | 990K| | 20550 (3)| 00:04:07 | | |
| 1 | SORT UNIQUE | | 14702 | 990K| 9608K| 19862 (3)| 00:03:59 | | |
|* 2 | VIEW | | 90794 | 6117K| | 18372 (3)| 00:03:41 | | |
| 3 | WINDOW SORT | | 90794 | 13M| 33M| 18372 (3)| 00:03:41 | | |
|* 4 | HASH JOIN | | 90794 | 13M| | 15251 (3)| 00:03:04 | | |
|* 5 | TABLE ACCESS BY INDEX ROWID| SOLAR_STATION | 1 | 78 | | 1 (0)| 00:00:01 | | |
|* 6 | INDEX UNIQUE SCAN | SOLAR_STATION_PK | 1 | | | 0 (0)| 00:00:01 | | |
| 7 | PARTITION RANGE ITERATOR | | 272K| 20M| | 15245 (3)| 00:03:03 | 10 | 11 |
| 8 | PARTITION HASH SINGLE | | 272K| 20M| | 15245 (3)| 00:03:03 | 1 | 1 |
|* 9 | TABLE ACCESS FULL | DATA | 272K| 20M| | 15245 (3)| 00:03:03 | | |
Predicate Information (identified by operation id):
2 - filter("MAX_DATE_STAMP"=TO_TIMESTAMP("DATE_STAMP"))
4 - access("A"."SOLAR_ID"="S"."SOLAR_ID")
5 - filter("S"."CLIMATE_ID"='611KBE0')
6 - access("S"."SOLAR_ID"='636')
9 - filter("A"."TIME_STAMP">=TO_DATE('2004-09-08 00:00:00', 'yyyy-mm-dd hh24:mi:ss') AND "YEAR"=2004 AND
"A"."SOLAR_ID"='636' AND "A"."TIME_STAMP"<=TO_DATE('2004-12-20 00:00:00', 'yyyy-mm-dd hh24:mi:ss'))The result was an error:
Error at line 0
ORA-01843: not a valid month -
Hi,
I am working on APO version 3.0A. I am trying to change the date range for the macros, i.e. iterations and weeks. I have activated the macro, but that change doesn't have any impact on the result, and when I checked the macro again the date range hasn't been changed.
if anyone has any idea working on this problem in version 3.0A?
I have made this changes in production system itself.
Thanks
Regards
JigneshJignesh,
In the poperties for step fo the Macros try the following:
Dont use Automatic Column Adjustment From Column
Dont use Automatic Column Adjustment To Column
Just give From Period and to Period and let it calculat the number of iterations.
Then GENERATE the macro (I assume by saying activating the macro in our query you meant generation as they are separate things in Macro Workbench).
Try this and see if the calculations are fine. I have a doubt that the combination of th checkboxes and iterations is causing the issue.
Regards,
Abhi -
Query for date range? JE
Hi,
I have seem some posts on the JE forum regarding quering for date range, but it is mostly using DPL.
Is there any way to do that using the JE API
Thanks,
MohammadHi Mohammad,
A date range query can be performed as a key range query. There's nothing special about dates except that you'll want to use a key binding that gives a meaningful sort order. If you're representing your dates in milliseconds, then a LongBinding (in com.sleepycat.bind.tuple) will work well. In general, use tuple bindings for keys, because they provide a meaningful sort order.
To perform a range query, this FAQ has some hints:
http://www.oracle.com/technology/products/berkeley-db/faq/je_faq.html#28
On range searches in general, they can be done with Cursor.getSearchKeyRange or with the SortedSet.subSet and SortedMap.subMap methods, depending on whether you are using the base API or the Collections API. It is up to you which to use.
If you use Cursor.getSearchKeyRange you'll need to call getNext to iterate through the results. You'll have to watch for the end range yourself by checking the key returned by getNext. This API does not have a way to enforce range end values automatically.
If you use the Collections API you can call subMap or subSet and get an Iterator on the resulting collection. That iterator will enforce both the beginning and the end of the range automatically.
Does this answer your question?
--mark -
Multi-month, year, and date-range views
My apologies for wasting everyone's time if I've missed something really obvious here, but am I correct in concluding that there is no way to generate anything beyond a static one-month view in iCal? No multi-month view? No year view? No "view date range"? At this stage of the game, how is it possible that something so elemental could be omitted from this program?
At this point I'm reduced to exporting each month to a pdf file and then arranging them as tiles on the screen. But there has to be a better way.
Short of a new version from Apple, are there any plug-ins that would do this? Does anyone have any other work-arounds? Thanks in advance.A quick search of the forums shows that this is a HIGHLY sought after feature (including by me). We all need to use the feed back link (below) to let Apple know this. In my experience with the tech support folks, they seem to have NO idea about what these forums say. In the past I have actually had them log in to these forums and search the issue I was calling them about and they have been blown away when they see the hundreds / thousands of posts with the very same thing they're discussing with me. So, as the wise man says .. "you don't ask, you don't get!" Use the form and let them know...
http://www.apple.com/feedback/ical.html -
How to get top 11 values per date range
I want to get the top 11 values by date range.
Sample Data
CREATE TABLE SAMPLE_DATA
DOMAIN_NAME VARCHAR2(100),
QTD NUMBER,
LOAD_DATE DATE
-- Insert
BEGIN
FOR lc IN 1..20
LOOP
FOR ld IN 1..30
LOOP
INSERT
INTO SAMPLE_DATA VALUES
'DM_'
||lc,
round(dbms_random.value(0,1000)),
SYSDATE-ld
END LOOP;
END LOOP;
COMMIT;
END;
SELECT *
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM SAMPLE_DATA
WHERE LOAD_DATE = TRUNC(SYSDATE-3)
ORDER BY QTD DESC
WHERE ROWNUM <=10
UNION ALL
SELECT 'Others' DOMAIN_NAME,
SUM(QTD) QTD,
LOAD_DATE
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT rownum rn,
DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM SAMPLE_DATA
WHERE LOAD_DATE = TRUNC(SYSDATE-3)
ORDER BY QTD DESC
WHERE rn > 10
GROUP BY LOAD_DATE
ORDER BY QTD DESC
-- Result
DOMAIN_NAME QTD LOAD_DATE
Others 2888 24/03/13
DM_1 1000 24/03/13
DM_20 933 24/03/13
DM_11 913 24/03/13
DM_3 743 24/03/13
DM_13 572 24/03/13
DM_12 568 24/03/13
DM_9 564 24/03/13
DM_6 505 24/03/13
DM_5 504 24/03/13
DM_2 480 24/03/13
Please, Help me get in one query this result using a range of date.
e.g
using LOAD_DATE BETWEEN '24/03/13' AND '25/03/13'
DOMAIN_NAME QTD LOAD_DATE
Others 2888 24/03/13
DM_1 1000 24/03/13
DM_20 933 24/03/13
DM_11 913 24/03/13
DM_3 743 24/03/13
DM_13 572 24/03/13
DM_12 568 24/03/13
DM_9 564 24/03/13
DM_6 505 24/03/13
DM_5 504 24/03/13
DM_2 480 24/03/13
Others 1948 25/03/13
DM_1 807 25/03/13
DM_8 764 25/03/13
DM_7 761 25/03/13
DM_11 656 25/03/13
DM_18 611 25/03/13
DM_17 523 25/03/13
DM_14 467 25/03/13
DM_19 447 25/03/13
DM_15 437 25/03/13
DM_6 380 25/03/13 Thank you in advance.I got the solution. Just sharing.
I used analytic functions that make my job easy.
Sample Data
DOMAIN_NAME QTD LOAD_DATE
DM_1 807 25/03/2013
DM_1 1000 24/03/2013
DM_2 226 25/03/2013
DM_2 480 24/03/2013
DM_3 244 25/03/2013
DM_3 743 24/03/2013
DM_4 48 25/03/2013
DM_4 413 24/03/2013
DM_5 164 25/03/2013
DM_5 504 24/03/2013
DM_6 380 25/03/2013
DM_6 505 24/03/2013
DM_7 761 25/03/2013
DM_7 212 24/03/2013
DM_8 764 25/03/2013
DM_8 308 24/03/2013
DM_9 354 25/03/2013
DM_9 564 24/03/2013
DM_10 214 25/03/2013
DM_10 367 24/03/2013
DM_11 656 25/03/2013
DM_11 913 24/03/2013
DM_12 37 25/03/2013
DM_12 568 24/03/2013
DM_13 332 25/03/2013
DM_13 572 24/03/2013
DM_14 467 25/03/2013
DM_14 87 24/03/2013
DM_15 437 25/03/2013
DM_15 450 24/03/2013
DM_16 238 25/03/2013
DM_16 299 24/03/2013
DM_17 523 25/03/2013
DM_17 143 24/03/2013
DM_18 611 25/03/2013
DM_18 145 24/03/2013
DM_19 447 25/03/2013
DM_19 464 24/03/2013
DM_20 91 25/03/2013
DM_20 933 24/03/2013 Top 11 QTD of DOMAIN_NAME per Data Range.
SELECT *
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT LOAD_DATE,
DOMAIN_NAME ,
QTD,
(DENSE_RANK() OVER (PARTITION BY LOAD_DATE ORDER BY QTD DESC )) AS RANK_QTD
FROM SAMPLE_DATA
WHERE trunc(load_date) BETWEEN '24/03/2013' AND '25/03/2013'
WHERE RANK_QTD <= 10
UNION ALL
SELECT 'Others',
SUM(QTD) AS QTD,
LOAD_DATE
FROM
(SELECT LOAD_DATE,
DOMAIN_NAME ,
QTD,
(DENSE_RANK() OVER (PARTITION BY LOAD_DATE ORDER BY QTD DESC )) AS RANK_QTD
FROM SAMPLE_DATA
WHERE trunc(load_date) BETWEEN '24/03/2013' AND '25/03/2013'
WHERE RANK_QTD > 10
GROUP BY LOAD_DATE
ORDER BY LOAD_DATE ASC,
QTD DESC
DOMAIN_NAME QTD LOAD_DATE
Others 2888 24/03/2013
DM_1 1000 24/03/2013
DM_20 933 24/03/2013
DM_11 913 24/03/2013
DM_3 743 24/03/2013
DM_13 572 24/03/2013
DM_12 568 24/03/2013
DM_9 564 24/03/2013
DM_6 505 24/03/2013
DM_5 504 24/03/2013
DM_2 480 24/03/2013
Others 1948 25/03/2013
DM_1 807 25/03/2013
DM_8 764 25/03/2013
DM_7 761 25/03/2013
DM_11 656 25/03/2013
DM_18 611 25/03/2013
DM_17 523 25/03/2013
DM_14 467 25/03/2013
DM_19 447 25/03/2013
DM_15 437 25/03/2013
DM_6 380 25/03/2013 -
Can not set data range for a numerical control
I want to set the maximum of data range to 5000, but it always went back to default value of 127.
WHy I can not change the data range? Thanka for explanations.
Message Edited by Dejun on 11-14-2007 11:47 PM
Attachments:
datarange.jpg 74 KBSo hit the 'Representation' button.
Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas
LabVIEW, programming like it should be! -
I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
[ABCTABLE]
ABCORDER
ABCPART
ABCSERIAL
ABCDATE
[ZYXTABLE]
XYZORDER
XYZPART
XYZSERIAL
XYZDATE1
XYZDATE2Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
on this computer. There are no "Null" fields in either of the tables.
This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
[MSORDR]
MSORDER
MSPART
MSSERIAL
MSOPNDATE
11111111
4444444
55555
2/4/2015
22222222
6666666
11111
1/6/2015
33333333
6666666
11111
3/5/2015
This table has one order for every part number and every serial number.
[GLORDR]
GLORDER
GLPART
GLSERIAL
GLSTARTDATE
GLENDDATE
ABC11111
444444
55555
1/2/2015
4/4/2015
ABC22222
666666
11111
1/5/2015
4/10/2015
AAA11111
555555
22222
3/2/2015
4/10/2015
Post Query table
GLORDER
MSORDER
GLSTARTDATE
GLENDDATE
MSOPNDATE
ABC11111
11111111
1/2/2015
4/4/2015
2/4/2015
ABC22222
22222222
1/5/2015
4/10/2015
1/6/2015
ABC22222
33333333
1/5/2015
4/10/2015
3/5/2015
This is the SQL minus the between date join.
SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART); -
No Data in Reports Details in Custom date range
Hello, iTunes U Public Site Manager Admins.
As the iTunes U Public Site Manager admin, I've been trying to access our institution's iTunes U Reports Details for a couple of days. (I send a monthly report of usage to our course/collection contributors.) When I custom the date range, under Details, there is zero entry; "No data available in table" message is shown.
This feature had been working well since Apple iTunes U added this enhancement on August 13, 2013. The report Details showed the exact stats for Browse, Subscribe, Download, Stream, and Enclosure for each course/collection in the custom date range.
Now under "Details", the data is shown only when the date range is Last 30 Days. It shows no data in custom date range when the Calendar is used to select a Start Date and End Date.
Has anyone else noticed this problem?
Thanks.
Q. WangErik.
I used your suggestion and it worked very well. This is how I did it.
Export the range of data that includes Feb. 1-Feb. 28, 2014 as .tsv file.
Open that file in Excel.
Add a blank column next to the Date column. Use function =Month() to just extract the month into the new column. Fill down the whole column. Then copy and paste special (value) into the same column (I have over 26,000 rows of data in the file.) Converting to Value will allow for the next step of PivotTable.
Create a PivotTable for the 26,000 rows of data. Use Month as the Report filter, iTunes_ID as the Row Labels, Select Browse, Subscribe, etc. as the Sum Values. (The result is a summary table with about 200 rows.)
I then do a Vlookup to my premade Master file to add Category (course, collection, resources) and Instructor Name to each of the 200 rows.
That will do it for my monthly report.
Thanks for your tip again. I did not know the .tsv file would have DATE for each item.
Sincerely,
Q. Wang -
Continious data range algorithm
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?
Oracle 11g.You're setting the wrong value for the start of a group when there is no (null) lagging end date. In my example I set the value to 0 when it was null as I was expecting each group to start at 1. In your case you've set the date to 1/1/1900 which isn't necessarily the day before the first start date of the group. Instead just default it to the start date - 1 to force a match...
SQL> ed
Wrote file afiedt.buf
1 with t as (select 1 as id, to_date('01.04.2013', 'DD.MM.YYYY') as val1, to_date('04.04.2013', 'DD.MM.YYYY') as val2 from dual union all
2 select 1, to_date('05.04.2013', 'DD.MM.YYYY'), to_date('06.04.2013', 'DD.MM.YYYY') from dual union all
3 select 1, to_date('07.04.2013', 'DD.MM.YYYY'), null from dual union all
4 select 2, to_date('01.04.2013', 'DD.MM.YYYY'), to_date('03.04.2013', 'DD.MM.YYYY') from dual union all
5 select 2, to_date('04.04.2013', 'DD.MM.YYYY'), to_date('07.04.2013', 'DD.MM.YYYY') from dual union all
6 select 2, to_date('09.04.2013', 'DD.MM.YYYY'), to_date('12.04.2013', 'DD.MM.YYYY') from dual union all
7 select 2, to_date('13.04.2013', 'DD.MM.YYYY'), null from dual union all
8 select 3, to_date('01.04.2013', 'DD.MM.YYYY'),to_date('03.04.2013', 'DD.MM.YYYY') from dual union all
9 select 3, to_date('04.04.2013', 'DD.MM.YYYY'), null from dual union all
10 select 4, to_date('01.04.2013', 'DD.MM.YYYY'), to_date('01.04.2013', 'DD.MM.YYYY') from dual union all
11 select 4, to_date('01.04.2013', 'DD.MM.YYYY'), null from dual
12 )
13 --
14 select id
15 ,val1 as "start"
16 ,val2 as "end"
17 ,lag(val2) over (partition by id order by val1)
18 ,case when
19 nvl(lag(val2) over (partition by id order by val1),val1-1) != val1-1 then
20 'hole or overlap'
21 else null
22 end as chk
23 from t
24* order by 1, 2
25 /
ID start end LAG(VAL2)OVER(PARTIT CHK
1 01-APR-2013 00:00:00 04-APR-2013 00:00:00
1 05-APR-2013 00:00:00 06-APR-2013 00:00:00 04-APR-2013 00:00:00
1 07-APR-2013 00:00:00 06-APR-2013 00:00:00
2 01-APR-2013 00:00:00 03-APR-2013 00:00:00
2 04-APR-2013 00:00:00 07-APR-2013 00:00:00 03-APR-2013 00:00:00
2 09-APR-2013 00:00:00 12-APR-2013 00:00:00 07-APR-2013 00:00:00 hole or overlap
2 13-APR-2013 00:00:00 12-APR-2013 00:00:00
3 01-APR-2013 00:00:00 03-APR-2013 00:00:00
3 04-APR-2013 00:00:00 03-APR-2013 00:00:00
4 01-APR-2013 00:00:00 01-APR-2013 00:00:00
4 01-APR-2013 00:00:00 01-APR-2013 00:00:00 hole or overlap
11 rows selected. -
Date range query problem in report
Hi all,
I have created a report based on query and i want to put date range selection but query giving problem.
If i am creating select list selection then it is working fine means it will display all records on the particular date.
But what i need is that user will enter date range as creation_date1,creation_date2 and query should return all the records between these date range. i want to pass it by creating items, i created two items and passing creation_date range to display all records but not displaying and if not passing date then should take null as default and display all records
Here is the query:
/* Formatted on 2006/12/10 20:01 (Formatter Plus v4.8.0) */
SELECT tsh."SR_HEADER_ID", tsh."SALES_DEPT_NUMBER", tsh."COUNTRY",
tsh."LOCAL_REPORT_NUMBER", tsh."ISSUE_DATE", tsh."SUBJECT",
tsh."MACHINE_SERIAL_NUMBER", tsh."MACHINE_TYPE", tsh."MACHINE_HOURS",
tsh."STATUS"
FROM "TRX_SR_HEADERS" tsh, "TRX_SR_PARTS" tsp
WHERE (tsh.status LIKE :p23_status_sp OR tsh.status IS NULL)
AND (tsh.machine_type LIKE :p23_machine_type_sp)
AND ( tsh.machine_serial_number LIKE
TO_CHAR (:p23_machine_serial_number_sp)
OR tsh.machine_serial_number IS NULL
AND ( TO_CHAR (tsh.failure_date, 'DD-MON-YY') LIKE
TO_CHAR (:p23_failure_date_sp)
OR TO_CHAR (tsh.failure_date, 'DD-MON-YY') IS NULL
AND ( TO_CHAR (tsh.creation_date, 'DD-MON-YY')
BETWEEN TO_CHAR (:p23_creation_date_sp)
AND TO_CHAR (:p23_creation_date_sp1)
OR TO_CHAR (tsh.creation_date, 'DD-MON-YY') IS NULL
AND (tsh.issue_date LIKE :p23_date_of_issue_sp OR tsh.issue_date IS NULL)
AND (tsh.country LIKE :p23_country_sp OR tsh.country IS NULL)
AND ( tsh.local_report_number LIKE TO_CHAR (:p23_local_rep_num_sp)
OR tsh.local_report_number IS NULL
AND ( tsp.part_number LIKE TO_CHAR (:p23_part_number_sp)
OR tsp.part_number IS NULL
AND tsh.machine_type IN (
SELECT DISTINCT machine_type
FROM trx_sales_dept_machine_list
WHERE sales_department_id IN (
SELECT DISTINCT sales_department_id
FROM trx_user_sales_department
WHERE UPPER (user_name) =
UPPER ('&APP_USER.'))
AND SYSDATE >= valid_from)
AND tsh.sr_header_id = tsp.sr_header_id
can any one tell me wat is wroung in this query.
Any other way to write this?
Thank You,
AmitHi User....
Here is some date range SQL that my teams uses with some success:
For date columns that do not contain NULL values, try this (note the TRUNC, it might help with your "today" problem).
The hard coded dates allow users to leave the FROM and TO dates blank and still get sensible results (ie a blank TO date field asks for all dates in the future.
AND TRUNC(DATE_IN_DATABASE)
BETWEEN
decode( :P1_DATE_FROM,
TO_DATE('01-JAN-1900'),
:P1_DATE_FROM)
AND
decode( :P1_DATE_TO,
TO_DATE('31-DEC-3000'),:
:P1_DATE_TO)
For date columns that contain NULL values, try this (a little bit trickier):
AND nvl(TRUNC(DATE_IN_DATABASE),
decode( :P1_DATE_FROM,
decode( :P1_DATE_TO,
TO_DATE('30-DEC-3000'),
NULL),
NULL)
BETWEEN
decode( :P1_DATE_FROM,
TO_DATE('01-JAN-1900'),
:P1_DATE_FROM)
AND
decode( :P1_DATE_TO,
TO_DATE('31-DEC-3000'),
:P1_DATE_TO)
Note the 30-DEC-3000 versus 31-DEC-3000. This trick returns the NULL dates when the FROM and TO date range items are both blank.
I hope this helps.
By the way, does anyone have a better way of doing this? The requirement is given a date column in a database and a FROM and a TO date item on a page,
find all of the dates in the database between the FROM and TO dates. If the FROM date is blank, assume the user want all dates in the past (excluding NULL dates). If the TO date is blank, assume that the user wants all of the dates in the future (excluding NULL dates). If both FROM and TO dates are blank, return all of the dates in the databse (including NULL dates).
Cheers,
Patrick -
Report for open invoice value against GR done within a date range
Dear experts ,
I need a report between date ranges for which there is a GR done , but invoice is pending .
Where can i get this ?
Regards
Anishi,
You can check few default PO reports wid proper paramater in it
or
Can check table EKBE
or
Check PO history in the PO doc
Or
Check the ME80FN
Regards
Priyanka.P -
Devolped an ALV report for daily cash receipts for selected date range
hi,
how to devlop an ALV report for daily cash receipts for selected date range.for this report what are the tables and fields we have to use.what is the selectionscreen&what is logic.give me sample report.hi,
how to devlop an ALV report for daily cash receipts for selected date range.for this report what are the tables and fields we have to use.what is the selectionscreen&what is logic.give me sample report. -
Devloped an ALV report for daily cash receipts for selected date range
hi,
how to devlop an ALV report for daily cash receipts for selected date range.for this report what are the tables and fields we have to use.what is the selectionscreen&what is logic.give me sample report.Hi,
You can develop simple reports using Report Painter.
You may be also interested in:
Check report SAPMF05A for credit memo
See the following Std reports on Payment Advices execute the Tcodes:
S_ALR_87009888
S_ALR_87009889
S_ALR_87009890
S_ALR_87009891
S_ALR_87009892
S_ALR_87009893
S_ALR_87009978
S_ALR_87009979
S_ALR_87009980
S_ALR_87009981
S_ALR_87009982
S_ALR_87009983
S_ALR_87010056
S_ALR_87010057
S_ALR_87010058
S_ALR_87010059
S_ALR_87010060
S_ALR_87010061
S_ALR_87010066
S_ALR_87010067
S_ALR_87012106
S_ALR_87012107
S_ALR_87012108
S_ALR_87012109
S_ALR_87012110
S_ALR_87012111
S_ALR_87012116
S_ALR_87012117
S_ALR_87012200
S_ALR_87012201
S_ALR_87012202
S_ALR_870122
S_ALR_87012204
S_ALR_87012205
S_ALR_87012350
S_ALR_87012351
S_ALR_87012352
S_ALR_87012353
S_ALR_87012354
S_ALR_87012355
sample ALV report:
tables:
marav. "Table MARA and table MAKT
Data to be displayed in ALV
Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-
matically determine the fieldstructure from this source program
Data:
begin of imat occurs 100,
matnr like marav-matnr, "Material number
maktx like marav-maktx, "Material short text
matkl like marav-matkl, "Material group (so you can test to make
" intermediate sums)
ntgew like marav-ntgew, "Net weight, numeric field (so you can test to
"make sums)
gewei like marav-gewei, "weight unit (just to be complete)
end of imat.
Other data needed
field to store report name
data i_repid like sy-repid.
field to check table length
data i_lines like sy-tabix.
Data for ALV display
TYPE-POOLS: SLIS.
data int_fcat type SLIS_T_FIELDCAT_ALV.
select-options:
s_matnr for marav-matnr matchcode object MAT1.
start-of-selection.
read data into table imat
select * from marav
into corresponding fields of table imat
where
matnr in s_matnr.
end-of-selection.
Now, we start with ALV
To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
The fieldcatalouge can be generated by FUNCTION
'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
report source, including this report.
The only problem one might have is that the report and table names
need to be in capital letters. (I had it )
Store report name
i_repid = sy-repid.
Create Fieldcatalogue from internal table
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = sy-repid
I_INTERNAL_TABNAME = 'IMAT' "capital letters!
I_INCLNAME = sy-repid
CHANGING
CT_FIELDCAT = int_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = i_repid
I_STRUCTURE_NAME = 'marav'
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = imat.
IF SY-SUBRC <> 0.
WRITE: 'SY-SUBRC: ', SY-SUBRC .
ENDIF.
Hope this will help.
Regards,
Naveen. -
How to create a date range in Web Application Designer
I am using 3.1 version of Web App Designer. I need to create a report with date ranges. I can get one date to work but not two (I need a start date and end Date). My Query has 0CALMONTH with a variable for Interval. When I select it as a dropdown (??) in Web App Designer, I only get one date prompt in web app designer.
Any suggestions??
Thanks
KristenHi Kristen,
I'm sorry i'm not coming to solve your problem,but for the trouble I have had,and I want to create a date picker in Web Application Designer,so if you have solved the problem ,please email to me? [email protected] ,thx very much!
best regards
zegion chan
Maybe you are looking for
-
My apps are in Italian and I can't change
I am trying to get new apps but everything is in Italian and I can't get anything. It's telling me that I have to change to the Italian store but I want to go back to the US apps. Can anybody help please?
-
Alternative way to backup phone?
Hey Everyone, I recently had an issue with one of the usb port pins being bent on my 8310 curve. This soon led to being unable to charge the phone or connect the phone to my computer via usb. Today, I received a brand new 8310, and I was wondering if
-
Why Is The Menu On The Master Page BELOW The Objects In Other Pages?
I added a menu on the master page using the Composition widget called featured news and it stays behind the other objects on normal pages. How do I fix this? Here are the pictures of the menu when it's closed and when it's open.
-
Interval Partition naming Issue (Oracle 11g R2 )
I need help on identifying latest partition: I am using Interval Partition for my table,which creates partition every month end based on inserted data. When oracle creates partition assigning its own name but users have automated reports using partit
-
Hi What is the OK_CODE for enter? I have ALV Grid Report with one fld in edit mode. If I enter wrong input it should goto selection screen. I have ONLI/ENTR/ENTE/space but not working. Please help me