Daily max(value) query for time period
I am looking to get the maximum value for every 24 hour period for a month. So for example my date range can be defined by...
select to_date('&date','mm yyyy')-1 + level as DateRange
from dual
connect by level <= '&days'
...where I can provide the first date of the month and number of days in the month or a lesser value if less time is required. So, the results of the above query plus 24 for the range. I thought a some googling would provide me what I needed, but my search came up empty.
I was hoping to do something like this...
select utctime, max(value) from table where utctime between....
Any guidance would be much appreciated!
Thanks!
Zewbie wrote:
Sorry about that...Oracle 10.2.0.5
create table x (utctime date,
pointnumber int,
value float)
insert into x values (to_date('02022012 232221','mmddyyyy hh24miss'), 10, 3.245);
insert into x values (to_date('02022012 202202','mmddyyyy hh24miss'), 13, 14.5);
insert into x values (to_date('02024012 103421','mmddyyyy hh24miss'), 10, 23.245);
insert into x values (to_date('02024012 042528','mmddyyyy hh24miss'), 10, 33.245);
insert into x values (to_date('02028012 022321','mmddyyyy hh24miss'), 14, 32.245);
insert into x values (to_date('02028012 205221','mmddyyyy hh24miss'), 10, 2.245);
insert into x values (to_date('02029012 211421','mmddyyyy hh24miss'), 14, 1.4345);
insert into x values (to_date('02029012 082221','mmddyyyy hh24miss'), 10, 3.245);Do you have dates 7000 years in the future, or ido you have typos?
So a query of the above would provide max daily value based on a pointnumber such as 10 for a given period.What are the results you want from the given data?
What role does pointnumber play in this problem?
If you want something like this:
A_DATE POINTNUMBER MAX_VALUE
02-Feb-2012 10 3.245
02-Feb-2012 13 14.5
02-Feb-2012 14
03-Feb-2012 10
03-Feb-2012 13
03-Feb-2012 14for the 2 days starting with February 2, 2012, then you can do this:
WITH days_wanted AS
SELECT DATE '2012-02-02' -- starting date
+ LEVEL - 1 AS a_date
FROM dual
CONNECT BY LEVEL <= 2 -- number of days wanted
SELECT d.a_date
, x.pointnumber
, MAX (x.value) AS max_value
FROM days_wanted d
LEFT OUTER JOIN x PARTITION BY (x.pointnumber)
ON TRUNC (x.utctime) = d.a_date
-- WHERE x.pointnumber = 10 -- If wanted
GROUP BY d.a_date, x.pointnumber
ORDER BY d.a_date, x.pointnumber
;
Similar Messages
-
Double record make it to single record in Query for perticular period in BW
Hi
In my ODS some of the records got doubled from Mar 17th to May 31st but from 1st of june its correct , its Open orders, i dont want to reload data again to that ODS , because its Open orders anyways its going to be close after some time , automatically it will become "0".
So i want tocalculate in query itself to make it single
please some one suggest me how can i do for that perticular period divided by 2
for example :
Open Orders (its In ODS)
120
140
20
10
50
I need output should be
60
120
10
5
25
Note : BW 3.1 Version
Thanks,
GAl
12hi,
You can create a a formula variable with replacement path on the Period(replace with key of Posting Date/Calday) and use it for comprision in the fomula like below
if posting date is in between date1 and date2
order value = order value/2.
else
ordervalue = ordervale.
In Bex Query designer you will have the below formula
(posting date formula variable >date1 and posting date formula variable <date2) * (Ordervalue/2) + ordervalue
But also note that when the order is closed the value of order value will net become zero since the value is doubled up in the DSO , when the delta records come into DSO the order will be closed but the value will still not become zero since the reverse image will give negative value of the actual order value.
For example if your order value is 100, in your DSO it will currently show the value is 200(doubled up). In the Delta the reverse value come as -100. So the final value will still be 100(200-100).
So the best solution will be to do selective deletion
Thanks,
Praveen
Edited by: Praveen kumar kamineni on Jun 11, 2010 11:06 AM -
Hi,
I have to make a query returning sum(xxx) for given period of 3 h.
table looks like:
start end xxx
0
3
6
Any suggestions are appreciated
DobbyConsider grouping by the trunc(end/3) or trunc(start/3) -- depending on whether you assign a range to a 3 hour block by when it starts or when it ends.
SELECT min(start) || ' - ' || max(end) AS period, SUM(xxx) AS sum_xxx
FROM your_table
GROUP BY trunc(end/3); -
Query for Previous Period Accumulated Dep
Can someone suggest me the best way to query the previous period accumulated depreciation for an asset.
I am facing with every way I have tried.
1st Way = Current Accumulated - Current Month Deprn (FA_DEPRN_SUMMARY). But in case of retired assets, the Current Accumulated becomes 0. So, this wudnt be a correct value to display.
2nd Way = Going back one period and taking the Accumulated Depreciation value. This is very problematic in queries. I got error for some dumb scenario I didnt test in the query. Apparently if there are more than 2 rows in FA_DEPRN_DETAIL, then 2 records will return instead of one.
Can someone help me out.
RegardsHi,
Check why the amounts in accum dep is calculating less amounts?
If your dep key and dep rates are correct, then there is no problem with the dep calculations.
Still if you feel that, a particular asset is to be depreciated more than the planned dep, you must perform a unplanned dep postings with Tcode ABAA
Before doing this you must have been done the config for the unplanned dep via the below tcodes.
OABU, and AO95.
Then try to post run planned dep with ABAA now, since this will only create an internal asset accounting document for the date 31.03.2009.
So if you run the dep run for the 12 period (if you follow apr-mar) with repeat option and by selecting list assets and execute it.
Here you see an separate dep doc will be generated for unplanned dep for your asset.
hope this might help you.
Thanks,
Srinu -
Error while running query for psoting period as varaible
hello,
I am running a query and posting period is variable single entry mandatory and when I run the query it gives me this error.
Variable 0I_PCURR could not be replaced.
Variable 0I_PCURR could not be replaced.
What might be the issue here ?
Thanks,Hi KM,
When you want to use a fiscal period, you need to say whick fiscal variant you'll be using.
This fiscal variant, depends on the company code you are using.
You might find out with some FI person how many fiscal variants are using at your company. If it's only one (or at least only one applies for this query), add 0FISCVARNT infoobject in your query and select the fiscal variant you were told.
But, as you are using a BC variable, maybe this variable needs to use 0comp_code infoobject to determine automatically the fiscal variant.
So,
1. try selecting a fiscal variant in filters.
2. try adding 0comp_code to your query.
hope this helps!
Regards,
Diego -
I want to count the rows based on the date values and time periods of a date column. e.g.
08/01/01 00:00 - 01:30 (row count)
08/01/01 01:30 - 02:00 (row count) etc.
I'm using the case function to create the time periods from the date column but I'm getting a syntax error, 'missing keyword' at between. How can I code the case statement to create the time periods. The following is the sql code I'm using.
select TO_CHAR(START_TIME, 'yyyy-mm-dd') as process_date,
case START_TIME
when TO_CHAR(START_TIME, 'hh24:mm') between '00:00' and '01:30' then '12:00 - 1:30 AM'
else 'unknown'
end as process_time,
count(*)
from V8_Event_Vw event
group by TO_CHAR(START_TIME, 'yyyy-mm-dd'), START_TIME
Thanks,
Tomselect TO_CHAR(START_TIME, 'yyyy-mm-dd') as process_date,
case when TO_CHAR(START_TIME, 'hh24:mm') between '00:00' and '01:30' then '12:00 - 1:30 AM'
else 'unknown'
end as process_time,
count(*)
from V8_Event_Vw event
group by TO_CHAR(START_TIME, 'yyyy-mm-dd'),
case when TO_CHAR(START_TIME, 'hh24:mm') between '00:00' and '01:30' then '12:00 - 1:30 AM'
else 'unknown'
end
*untested (as if I really needed to say that) -
Daily Max Value and Time of Max
Hi I need a little help.
I have a table like this -
date_time------------------------wind_speed------------direction
01-Jan-2010 09:00:00------------10------------------------150
01-Jan-2010 12:00:00------------15------------------------170
01-Jan-2010 15:00:00------------20------------------------170
01-Jan-2010 18:00:00------------18------------------------160
01-Jan-2010 21:00:00------------11------------------------120
02-Jan-2010 09:00:00------------20------------------------100
02-Jan-2010 12:00:00------------30------------------------190
02-Jan-2010 15:00:00------------20------------------------170
02-Jan-2010 18:00:00------------20------------------------100
02-Jan-2010 21:00:00------------10------------------------090
03-Jan-2010 09:00:00------------35------------------------200
03-Jan-2010 12:00:00------------30------------------------290
03-Jan-2010 15:00:00------------40------------------------270
03-Jan-2010 18:00:00------------45------------------------200
03-Jan-2010 21:00:00------------30------------------------290
I want a script that will pull out the daily maximum wind speed, the direction that this maximum wind speed was coming from, and the exact time that the daily maximum wind speed was recorded. Something like this -
date-------------------daily_max---direction-------time_recorded
01-Jan-2010------------20------------170--------01-Jan-2010 15:00:00
02-Jan-2010------------30------------190--------02-Jan-2010 12:00:00
03-Jan-2010------------45------------200--------03-Jan-2010 18:00:00
Any help offered would be great.
Thanks
Edited by: user10768199 on 26-Mar-2010 04:16select trunc (dt) dt
, max (wind_speed) keep (dense_rank first order by wind_speed desc) wind_speed
, max (direction) keep (dense_rank first order by wind_speed desc) direction
, max (dt) keep (dense_rank first order by wind_speed desc) date_time
from test
group by trunc (dt)as in
SQL> with test as
2 (
3 select to_date ('01-Jan-2010 09:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 10 wind_speed, 150 direct
ion from dual union all
4 select to_date ('01-Jan-2010 12:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 15 wind_speed, 170 direct
ion from dual union all
5 select to_date ('01-Jan-2010 15:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 20 wind_speed, 170 direct
ion from dual union all
6 select to_date ('01-Jan-2010 18:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 18 wind_speed, 160 direct
ion from dual union all
7 select to_date ('01-Jan-2010 21:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 11 wind_speed, 120 direct
ion from dual union all
8 select to_date ('02-Jan-2010 09:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 20 wind_speed, 100 direct
ion from dual union all
9 select to_date ('02-Jan-2010 12:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 30 wind_speed, 190 direct
ion from dual union all
10 select to_date ('02-Jan-2010 15:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 20 wind_speed, 170 direct
ion from dual union all
11 select to_date ('02-Jan-2010 18:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 20 wind_speed, 100 direct
ion from dual union all
12 select to_date ('02-Jan-2010 21:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 10 wind_speed, 090 direct
ion from dual union all
13 select to_date ('03-Jan-2010 09:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 35 wind_speed, 200 direct
ion from dual union all
14 select to_date ('03-Jan-2010 12:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 30 wind_speed, 290 direct
ion from dual union all
15 select to_date ('03-Jan-2010 15:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 40 wind_speed, 270 direct
ion from dual union all
16 select to_date ('03-Jan-2010 18:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 45 wind_speed, 200 direct
ion from dual union all
17 select to_date ('03-Jan-2010 21:00:00', 'dd-Mon-yyyy hh24:mi:ss') dt, 30 wind_speed, 290 direct
ion from dual
18 )
19 select trunc (dt) dt
20 , max (wind_speed) keep (dense_rank first order by wind_speed desc) wind_speed
21 , max (direction) keep (dense_rank first order by wind_speed desc) direction
22 , max (dt) keep (dense_rank first order by wind_speed desc) date_time
23 from test
24 group by trunc (dt)
25 ;
DT WIND_SPEED DIRECTION DATE_TIME
01-JAN-10 20 170 01-JAN-10
02-JAN-10 30 190 02-JAN-10
03-JAN-10 45 200 03-JAN-10 -
How to build MDX query for two periods of time?
I have the following MDX:
SELECT NON EMPTY
[Measures].[Returns],
[Measures].[Returns]
ON COLUMNS,
NON EMPTY
([Employees].[Company].[Company].ALLMEMBERS )
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM
SELECT
STRTOSET("[Exec Date].[Hierarchy].[Month Num].&[2014]&[1]", CONSTRAINED)
) ON COLUMNS FROM [cbSales]
WHERE
IIF(
STRTOSET("[Exec Date].[Hierarchy].[Month Num].&[2014]&[1]", CONSTRAINED).Count = 1,
STRTOSET("[Exec Date].[Hierarchy].[Month Num].&[2014]&[1]", CONSTRAINED),
[Exec Date].[Hierarchy].currentmember
Both columns shows returned data for month 2014/01
I want to have data for the next month (2014/02) in the second column.
How can I change the query to achieve my goal.Hi,
To achieve this you need to create another measure with the help of ParallelPeriod function. Check the following example;
WITH MEMBER [Measures].[Sales Amount Current] AS [Measures].[Sales Amount]
MEMBER [Measures].[Sales Amount Next] AS ([Measures].[Sales Amount], PARALLELPERIOD([Date].[Calendar].[Month],-1, [Date].[Calendar].CURRENTMEMBER)), format_string = "Currency"
MEMBER [Measures].[Current Month] AS [Date].[Calendar].CURRENTMEMBER.Member_Caption
MEMBER [Measures].[Next Month] AS PARALLELPERIOD([Date].[Calendar].[Month],-1, [Date].[Calendar].CURRENTMEMBER).Member_Caption
SELECT {[Measures].[Current Month], [Measures].[Sales Amount Current], [Measures].[Next Month], [Measures].[Sales Amount Next]} ON COLUMNS,
{[Product].[Category].[Category].MEMBERS} ON ROWS
FROM [Adventure Works]
WHERE [Date].[Calendar].[Month].&[2007]&[10]
For ParallelPeriod specify -1 for "Numeric Expression" to navigate forward of the date hierarchy.
Best regards,
Chandima
Thanks, nice answer -
Query for Future period on a non cumulative cube
Hi Colleagues,
I have a non cumulative cube. It has data till June,2006. When I query on the cube to report the balance with period as "July,2006" it doesnot return anything. What I expected is that it would show me the balance value as of June,2006 which is the last period for which there is data.
Am I missing anything ?
Regards,
priyadarshiIf you filter by jul06 and there is no data in cube, no matches with selection happens. You need to select any data to apply calculation of balance, try to select a range of months, with an offset.
Maybe if you put the month in free characteristics instead in filter section ir worked. -
Finding std query for Time booking report in BW
Hello,
Time booking for service engineers are done in CRM Service. Need to furnish report on this time booking in BI portal.Can anyone help me in finding std. query built in BI on time booking.
Regards
Devika.SHi gabbeta,
not sure, but I try:
1) you want in single columns values <4 or <8...:
You can use Formula with boolean operator '<'. It gives you as feed-back 1 or 0 if corresponding to the operator.
2) you want single columns for single values of Priority:
You create a set of Restricted Key Figures with the corresponding value of Priority.
3) you can combine previous settings if you need both situation: Restricted Key Figure and values greater or less then 4, 8, 12.
Ciao.
Riccardo. -
30EA2 - UNIT TESTING - Dynamic Value Query truncating time from dates.
So i've been using the SQL Developer Unit Testing facility (very nice by the by) for a bit now and just recently upgraded to the latest beta release (3.0.02.83). It looks like a bug was introduced whereby the dynamic value queries are truncating all the time information from any DATE Data Types.
This causes some serious sadness for my current test cases and for me since i have to revert to the previous beta release :)Irian wrote:
I noticed that in the new 30EA2 the parameter:
AddVMOption -Doracle.jdbc.mapDateToTimestamp=false has been introduced by default in
[SQLDEveloper_install_dir]/sqldeveloper/bin/sqldeveloper.confmaybe this has something to do with the incorrect date behaviour, try to remove the parameter and check again.That seems to have done the trick.
Many thanks! -
How prepare Query for time series algorithm?
Hi every one,
i want next 6 month prediction, how prepare the Query ,
I have Date column,Crime column,Incidents Column,I going with next 6 month so how we get date columns month wise or date wise,
if month wise means,How split the Year and month from date colum??
Please i need some help.....waiting for reply.....
pandiyanHi Leo,
Thanks a lot for replay.
but using help of this blog also this problem not solve.
is this problem can we solve using "Seasonal Decomposition of Time Series by Loess".
Regards,
Manish -
Report for Stock Value Balances for previous periods
Hi, I would like to fing a standard report on SAP to provide the monthly stock balances per period the same way as MB5L, but with the functionality to inform the year
Hi
Try using report FS10N for all the balnces period wise for a specific year, you need to mention the G/L accounts from MB5L report.
Thanks & Regards
Kishore -
Get Time Period Values 12.0
All,
Is there any way to get the values of configured Time Periods at runtime. For example get the current shift start and and end time values?
Regards,
ChristianThis little trick is also an excellent way to understand how the time engine works, in a WYSIWYG manner. If you test your Simulator Tag query template from the Template Editor or WB and select text/xml the answers are revealed.
A simple Q/A for situations like:
What happens if I put Time=Today@08:00:00 and Duration = -1 and DurationUnits = D?
Regards,
Jeremy -
Location stock with value.. in concern period
Great Gurus
Is there any report in SAP MM standard, that can location stock and value in concened time period.
Selection Parameters:
Periods selection ( Posting date from, To)
Material selection
Material type selection
there is a report : Stock overview ( Russia) , but it takes to much time.
Regards\Adnanhi,
you can see the report MB52 for the requirement...
Here donot tick for the "Do not display values"....
This will surely solve your problem...
Regards
Priyanka.P
Maybe you are looking for
-
IPhone 5 battery life and speaker issues
Hey guys. Not sure if anyone else is having this issue but firstly. The battery life *****. And really *****. I let phone completely drain at least twice a month. Then fully charge it. Not a huge user but data I know eats it. We are talking literally
-
IPhone keyboard stops appearing
I have an issue with the keyboard not responding. Use a UINavigationViewcontroller and have your drill-down page contain a UIScrollView with a UITextView as the subview. If you drill down and click to get the keyboard, you'll never be able to drill d
-
Using XI as a FTP Server ?
Hi I would like to use the XI for transferring files from 2 systems, both of them have a FTP server installed, they don't share the same file system with the XI, I would like to have the following scenario : 1. Application A create a data file. 2. Ap
-
How to use Enterprise Data Protection in Windows 10 ?
I have installed Windows 10 technical preview for Enterprise on my machine. one of the goals is to explore the "Enterprise Data protection" feature in Windows 10. However, I am unable find any way to use this feature. Is this feature part of the prev
-
Hi folks, I'm trying to increase the length of the individual dash strokes (i.e. shorten the gaps between the dashes). Does anyone know how to do this; alternatively, is there a way I can make a custom dashed line? cheers Rich