Getting values for the lastest day
Have a few million records, I need to compute the difference of two columns for the last day with available data
It appears like the function: max should do what I need. e.g.,
select sDate, sStorage, sInflow, sRelease, sInflow-sRelease as diff, sElevation from Summary where max(sDate)=sDate;
But I get this error: group function is not allowed here
Yet: select max(sdate) from summary returns the latest date of the field (column)
Any help is greatly appreciated
Thanks
J-
you missed some parens
SELECT sdate, sstorage, sinflow, srelease, sinflow -srelease AS diff, selevation
FROM summary
WHERE sdate = (
SELECT MAX(sdate)FROM summary
or use analytics (sometimes faster for this type)
SELECT sdate, sstorage, sinflow, srelease, diff, selevation
from
SELECT sdate, sstorage, sinflow, srelease, sinflow -srelease AS diff, selevation
, row_number() over(order by sdate desc) rn
FROM summary
where rn=2
Similar Messages
-
How can I get null values for the later weeks
Hi All,
When I execute this code I get the records till current week.
How can I display the output so that I get null values for the later weeks. (with the help of v_numOfWeeks variable in the code)
Thanks,
Vikram
DECLARE
v_query VARCHAR2(4000);
TYPE ref_cursor IS REF CURSOR;
v_refcur ref_cursor;
v_sum NUMBER;
v_id NUMBER;
v_name VARCHAR2(1000);
v_weeknum NUMBER;
v_pernum NUMBER;
v_numOfWeeks NUMBER := 5;
BEGIN
v_query := ' SELECT SUM(product_bkg), postn_id, postn_tbl.postn_name, b.week_num, b.period_num
FROM ops_cv_extract b, (SELECT row_id, desc_text postn_name
FROM s_postn) postn_tbl
WHERE lvl_6_id = 5767
AND fiscal_year = 2008
AND b.week_num < 4
AND b.period_num = 3
AND b.postn_id = TO_NUMBER(postn_tbl.row_id)
GROUP BY postn_id, postn_tbl.postn_name, b.week_num, b.period_num
ORDER BY postn_tbl.postn_name, b.week_num';
OPEN v_refcur FOR v_query;
LOOP
FETCH v_refcur INTO v_sum, v_id, v_name, v_weeknum, v_pernum;
EXIT WHEN v_refcur%notfound;
dbms_output.put_line('P'|| v_pernum||'W'|| v_weeknum||' '||v_name||' '||v_sum);
END LOOP;
END;
This is the output when I execute this code.
P3W1 COMM CNTRL ISAM 213 26961.61
P3W2 COMM CNTRL ISAM 213 12870.4
P3W3 COMM CNTRL ISAM 213 245.88
P3W1 COMM CNTRL ISAM 273 72831.2
P3W2 COMM CNTRL ISAM 273 8739.38
P3W3 COMM CNTRL ISAM 273 3764.92
P3W1 COMM CNTRL TAM 213 49844
P3W2 COMM CNTRL TAM 213 20515.17
P3W3 COMM CNTRL TAM 213 16167.46
P3W2 COMM CNTRL TAM 216 12561.4
P3W3 COMM CNTRL TAM 216 2027.1
P3W1 COMM CNTRL TAM 273 -3336.71
P3W2 COMM CNTRL TAM 273 -1376.68
P3W3 COMM CNTRL TAM 273 19707.42
P3W1 Damon Walters -609.07
P3W2 Damon Walters 30030.24
P3W3 Damon Walters 37475.1
This is the output I'd like to get
P3W1 COMM CNTRL ISAM 213 26961.61
P3W2 COMM CNTRL ISAM 213 12870.4
P3W3 COMM CNTRL ISAM 213 245.88
P3W4 COMM CNTRL ISAM 213
P3W5 COMM CNTRL ISAM 213
P3W1 COMM CNTRL ISAM 273 72831.2
P3W2 COMM CNTRL ISAM 273 8739.38
P3W3 COMM CNTRL ISAM 273 3764.92
P3W4 COMM CNTRL ISAM 273
P3W5 COMM CNTRL ISAM 273
P3W1 COMM CNTRL TAM 213 49844
P3W2 COMM CNTRL TAM 213 20515.17
P3W3 COMM CNTRL TAM 213 16167.46
P3W4 COMM CNTRL TAM 213
P3W5 COMM CNTRL TAM 213
P3W1 COMM CNTRL TAM 273 -3336.71
P3W2 COMM CNTRL TAM 273 -1376.68
P3W3 COMM CNTRL TAM 273 19707.42
P3W4 COMM CNTRL TAM 273
P3W5 COMM CNTRL TAM 273
P3W1 Damon Walters -609.07
P3W2 Damon Walters 30030.24
P3W3 Damon Walters 37475.1
P3W4 Damon Walters
P3W5 Damon Walters Edited by: polasa on Oct 28, 2008 6:42 PMSure, in a Single SQL ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:00.01
satyaki>
satyaki>
satyaki>-- Start Of Test Data --
satyaki>with week_tab
2 as
3 (
4 select 1 period_num, 1 week_num, 10 bkg1 from dual
5 union all
6 select 1, 2, 40 from dual
7 union all
8 select 1, 3, 30 from dual
9 union all
10 select 1, 2, 20 from dual
11 union all
12 select 1, 1, 10 from dual
13 union all
14 select 1, 1, 20 from dual
15 union all
16 select 1, 3, 10 from dual
17 union all
18 select 2, 1, 15 from dual
19 union all
20 select 2, 2, 20 from dual
21 union all
22 select 2, 3, 10 from dual
23 union all
24 select 2, 1, 15 from dual
25 union all
26 select 2, 2, 30 from dual
27 union all
28 select 2, 3, 20 from dual
29 )
30 -- End Of Test Data --
31 select period_num,
32 week_num,
33 (
34 select sum(week_tab.bkg1)
35 from week_tab
36 where period_num = m.period_num
37 and week_num = m.week_num
38 group by week_num, period_num
39 ) sum_bkg1
40 from (
41 select dum.week_num,
42 wk.period_num
43 from (
44 select 1 week_num from dual
45 union all
46 select 2 from dual
47 union all
48 select 3 from dual
49 union all
50 select 4 from dual
51 union all
52 select 5 from dual
53 ) dum ,
54 (
55 select distinct period_num
56 from week_tab
57 ) wk
58 ) m;
PERIOD_NUM WEEK_NUM SUM_BKG1
1 1 40
1 2 60
1 3 40
1 4
1 5
2 1 30
2 2 50
2 3 30
2 4
2 5
10 rows selected.
Elapsed: 00:00:00.48
satyaki>Regards.
Satyaki De. -
How to get the values for the Authorization Object Fields....
Hi Everyone,
I'm pretty new to the SAP Security and have been working on the Basis sides...I created a new role in PFCG and added a few transactions (ME13) and clicked on the Authorizations tab. In there, the authorization tree is in yellow and red. After providing the Org Values, only the yellow lights remain (apart from the green one ofcourse). Now how do we get the values for the different auth obj fields that are in yellow... say for example
Conditions COND
Maintain Condition: Auth. for Use/Appl./Cond.Type/Table V_KOND_VEA
Activity 03 ACTVT
Application KAPPL
Condition table KOTABNR
Condition Type KSCHL
Usage of the condition table KVEWE
Here the values for V_KOND_VEA fields e.g. KAPPL, KOTABNR etc are missing.
My question is how do we get these values in regard to the requirement provided by the client...is it the functional guys who provide these values or else how is a security person supposed to know it...
All the help in this regard is sincerely appreciated along with the awarding of points...Hey thanks Alex and Catastrophe for the quick response...
I'll be sitting with the functional team and reviewing the roles created.
Thanks for all the help once more
Regards,
Akash. -
How do I get a new value for the service name field and update it in Connection Properties?
I am running Windows Vista. I just upgraded to Firefox 4. When I try to log on to the internet, it tells me the proxy server is refusing connections. A diagnostic reported Error 815 and said the remote server is not responding because there is an invalid value for the "Service Name" field. It said to get a new value and update it in Connection Properties. How do I do this?
When you create a new film script, the first page you see is a title page.
The page after this title page is the one where you generally type in your scenes.
It looks like you are facing some issue and not able to delete any text.
Can you please send me this script so that I can have a better look at your issue?
You can save this script to disk by using option 'File -> Save to disk'. This will create a '.stdoc' file on your system.
Just mail this '.stdoc' file to me at 'roverma <at> adobe <dot> com'
Thanks -
How to get the value for the LIT_Withheld field in the city tax form?
I am trying to get the value for the LIT_Withheld field on the city tax form , PAYUSEET.. This is not a database column but is generated based on some conditions.. Appreciate the help. Thanks, Suguna
Hi Abhmanyu,
Thanks for your response.
Search Help Name : ZZ_MG_MARITAL_VH
Selection Method : T502T
Search help parameters are SPRSL, FAMST, FTEXT,
Can u provide me a sample code to fetch the value of corresponding text.
Thanks,
Hari -
How to get the date for the last day of a week?
Is there a easy way to get the date for the last day of week?
eg a week starts on monday and end on sunday
January 11, 2005 is the start date for the week
January 17, 2005 is the end date for the week
or
say
February 26, 2003 is the start date for the week
March 5, 2003 is the end date for the week
I just need a simple way of figuring that out....
I figured out how to get the start date for the week but just can't get the latter..
formatting of the date is not of a concern.. that I know how to do
thanks in advanceHow about something like the following?
Calendar someDay = new GregorianCalendar(2005,0,11);//2005 Jan, 11
//Note above that January is 0, not 1, as counting starts from 0.
someDay.add(Calendar.DAY_OF_MONTH,6); //add 6 days
java.util.Date lastDayOfWeek = someDay.getTime();
//If someDay was the start of a week, lastDayOfWeek should now be
//the last day of that week.
System.out.println(lastDayOfWeek.toString() ); -
How to get the lock and block occured for the full day
Hi,
How to monitor the lock and blocks occurred for the full day? i need to get it by end of the day. is there any script for this?Hi,
How to monitor the lock and blocks occurred for the full day? i need to get it by end of the day. is there any script for this?
Why would you like to collect information about locks and let me tell you, you cannot collect information about ALL locks which were taken and even thinking about it is pointless.
Coming to blocking if you have heavy system with huge concurrency there is bound to be blocking which is necessary and good for RDBMS but if the blocking remains for long time then this is a issue.
There is DMV sys.dm_tran_locks which tell you what all locks are being taken. You can see various examples mentioned in DMV online documentation and can schedule the query to run every 5
mins and insert its record in table which you can refer at end of the day.
This task would be made very easy if you have Monitoring tool which gives you information in your mail every time blocking occurs I have Spotlight in my environment.
If you are looking for doc for troubleshooting blocking below is one you can refer
http://support.microsoft.com/kb/224453
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it.
My TechNet Wiki Articles -
Creation of a Query to show the values for the current month and the last 12 months data.
Dear All,
Good day!
I have to create a Query with the below requirement.
I have to create a Query to show the values for the current month and the last 12 months data.
Can you please guide me how to achieve this ??
thank you,
Regards,
HemaHema
explain the exact problem..? as you mentioned you want to create query to show values for current month and last 12 months.. so I think you want to show values for 12 months from current data.. you can achive this by multiple way..
you can have selection screen and field with date .. and restrict based on system current date and 12 months before or you can handle this at your target.. .. I mean there are multiple ways to restrict data by date range..
for some more hints..
http://www.forumtopics.com/busobj/viewtopic.php?t=34393&sid=7fba465d0463bf7ff5ec46c128754ed6
http://businessintelligence.ittoolbox.com/groups/technical-functional/cognos8-l/how-to-display-last-12-months-in-report-based-on-todays-date-3231850
http://scn.sap.com/thread/3217381
search on SDN you will get many other ways..
Thanks,
Bhupesh -
Last Month value for the keyfigure in Report
HI ALL,
how do we get keyfigure value for the last month in the report.
for ex: for amount keyfigure should come for the last month rest of the key figures should come for the current month values.
SBU | AMOUNT (LAST MONTH VALUE) | QTY(CURRENT MONTH) | NETPROFIT(CURRENT MONTH)
The above shown is ex as i required in same manner. Even i restricted with calmonth offset value -1 in keyfigure but it is not working. please help me to get solution .
Thanks
Pinky ReddyHi Pinky,
It is not advisable to use offset to get the previous month value.This is not effective in the case when your current month is Jan & u have to get the previous year's dec month value.It is always better to opt for Exits
Do use the code mentioned below.
Note:- ZCUSMFIS3 - Variable in the selection screen for entering current month
'ZPREVPER - Variable with which the amount key figure has to be resticted.
WHEN 'ZPREVPER'.
IF I_STEP = 2. "after the popup
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZCUSMFIS3'.
V_PERIOD = LOC_VAR_RANGE-LOW+4(3).
V_FYEAR = LOC_VAR_RANGE-LOW+0(4).
V_FVARIANT = 'B1'.
V_FISCPERYEAR = LOC_VAR_RANGE-LOW.
IF V_PERIOD = '001'.
V_PERIOD = '012'.
V_FYEAR = V_FYEAR - 1.
CONCATENATE V_FYEAR V_PERIOD INTO V_FISCPERYEAR.
ELSE.
V_FISCPERYEAR = V_FISCPERYEAR - 1.
LOC_VAR_RANGE-LOW = V_FISCPERYEAR.
ENDIF.
CLEAR L_S_RANGE.
L_S_RANGE-LOW = LOC_VAR_RANGE-LOW. "YYYYMMDD - DD will indicate the no of days
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
APPEND L_S_RANGE TO E_T_RANGE.
EXIT.
ENDLOOP.
ENDIF.
Hope this provides the solution for your requirement.
Regards,
Saswati. -
NOT Getting Values for LOCATION...on MultiProvider REPORT
HI All,
I have a MultiProvider on 4 cubes.All these 4 cubes having object LOCATION. I can see data in all cubes for LOCATION. I am running a report on this MultiProvider.
Problem:
I am not getting Values for LOCATION. Why?
What I did:
I checked all location objects of all 4 cubes @ MultiProvider level .
I didn't use any Infoprovider in Qry designer sections.
Please suggest. What is the reason how to solve..
THanks & Regards.
Sri.
Edited by: siri26 k on Dec 5, 2008 10:41 AM
Edited by: siri26 k on Dec 5, 2008 10:41 AMhello,
in the identification tab of the MP,make sure you have checked all four checkboxes across the 4 infoproviders.
then in Listcube T-Code, select your MP,display the records based on selection inputs and see if location is populated.
If the data is not coming in listcube, then it will not come in the Query too.
Reg,
Dhanya -
% is not getting correctly for the Grand Total Row in OBI10g
Hi,We have a report in table view with the following structure.
Name Target Act %Ach
ABC 100 50 50
XYZ 200 10 5
Total 300 60 27.5
The value for the %Ach Total row should be 20% but in the report it is showing as 27.5.
any one observed this ,how to correct this??
ThanksHi,
To get grand total correctly..configure instanceconfig.xml and put..
<ReportAggregateEnabled>true</ReportAggregateEnabled> between <serverinstace>..
refer..
http://obiee101.blogspot.com/2009/09/obiee-grand-totals-with-calculated.html
Hope it solves ur problem -
We are having a custom WebADI, containing a field (Employee Name) which is a LOV.
The LOV has ID : Person ID, Meaning : Employee name, Description : Position Name.
There are multiple records with same Employee name but different Person ID.
If I select an Employee in the LOV which has multiple records (through different IDs), I am getting an error in WebADI:
"Enter a valid EMPLOYEE_NAME.
XX is invalid. Enter a valid value for the Mapping column EMPLOYEE_NAME"
The Query for the LOV is correct and is returning correct records.
Any pointers on this issue highly appreciated.Hi,
The problem could be with HR security profile attached to the responsibility from where you are launching the spreadsheet. Check it once.
Thanks. -
Adjusting Portal Pages throws "Specify a value for the property {0}"
I found (with the help of our friends at OSS) the setting I need to change with to adjust the Runtime frame size for Guided Procedures.
It's quite logical really, since GP is just a bunch of pages in the portal it would make sense to find them in the Portal Content option ... So there it was.
Content Administration > Portal Content
Search for content and go to Process Instance. The following part shows the 3 main content parts of the GP Runtime window. As you can see in the third container are the two elements that contain your content. "Content Area" and "Public Content Area".
Open those two areas (scroll down in the list in the middle, select one and press open) and change the value of Height Type from "Fixed" to "Automatic" or "Full Page".
This is where I get my error (see the link below for a screenshot as well): When I try to change a value, any value or just open for modifying and try saving again (without changing anything) I get this error:
[http://wow.telenet.be/delaware/property0.jpg]
Specify a value for the property
Now I don't know if there any portal expert watching this thread, but it seems as though all those pages have been wrongly configured from the start. And until I figure out the right configuration I won't be able to save them either way.
My question is two-fold:
1) Can anyone provide me with all the settings he has for this component so I can compare them to mine?
2) How do I fix this error? I'm assuming every page in the portal gives the same error?
Thanks in advance,
Frederik-Jan
Edited by: Frederik-Jan Roose on Apr 1, 2008 11:33 AM
Edited by: Frederik-Jan Roose on Apr 1, 2008 11:33 AMI found (with the help of our friends at OSS) the setting I need to change with to adjust the Runtime frame size for Guided Procedures.
It's quite logical really, since GP is just a bunch of pages in the portal it would make sense to find them in the Portal Content option ... So there it was.
Content Administration > Portal Content
Search for content and go to Process Instance. The following part shows the 3 main content parts of the GP Runtime window. As you can see in the third container are the two elements that contain your content. "Content Area" and "Public Content Area".
Open those two areas (scroll down in the list in the middle, select one and press open) and change the value of Height Type from "Fixed" to "Automatic" or "Full Page".
This is where I get my error (see the link below for a screenshot as well): When I try to change a value, any value or just open for modifying and try saving again (without changing anything) I get this error:
[http://wow.telenet.be/delaware/property0.jpg]
Specify a value for the property
Now I don't know if there any portal expert watching this thread, but it seems as though all those pages have been wrongly configured from the start. And until I figure out the right configuration I won't be able to save them either way.
My question is two-fold:
1) Can anyone provide me with all the settings he has for this component so I can compare them to mine?
2) How do I fix this error? I'm assuming every page in the portal gives the same error?
Thanks in advance,
Frederik-Jan
Edited by: Frederik-Jan Roose on Apr 1, 2008 11:33 AM
Edited by: Frederik-Jan Roose on Apr 1, 2008 11:33 AM -
11g-[nQSError: 42029] Subquery contains too many values for the IN predicat
Hi,
I am having 2 reports one is for subquery which returns inputs to Main report. Actually the report was working fine in 10g. But in 11g we are gettting following error:
View Display Error
Odbc driver returned an error (SQLExecDirectW).
Error Details
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 42029] Subquery contains too many values for the IN predicate.Please have your System Administrator look at the log for more details on this error. (HY000)
Please have your System Administrator look at the log for more details on this error.
Getting same error after modofying the parameter value MAX_EXPANDED_SUBQUERY_PREDICATES to 12000
Please suggest what could be the other reason it may fail or any other settings we need to check.
Regards,
ckengckeng,
Normally the IN clause has restriction of 10000 values in general sql/plsql we will go with inline queries i think model your rpd to generate inner queries
select * from emp where dept_id in (Select distinct dept_id from dept);
or have a condition/filter on sub report and make one more inner report with sub-filter but definitely it will cause performance issues.
thanks,
Saichand.v -
I am using a table in Numbers to plot daily graph lines. Mood swings of how I am on the day, i"m a depressive.
If I fill a cell with a step box at say zero it plots the graph. I can't actually set the cell value until the actual day but the graph plots it at zero when I don't want it to plot anything. Is there a work around. so thatbgraph only plots on the day?The answer is (sort of) in your subject, but edited out of the problem statement in the body of your message.
When you use a stepper or a slider, the value in the cell is always numeric, and is always placed on the chart if that cell is included in the range graphed by the chart.
But if you use a pop-up menu cell, you can specify numeric or text values in the list of choices for in the menu. Numeric values will be shown on the chart. Text values will not.
For the example, the values list for the pop-up menu was:
5
3
1
Choose
-1
-3
-5
The first pop-up was set to display Choose, then the cell was filled down the rest of the column. Any text value (including a single space, if you want the cell to appear blank) may be used instead of Choose.
For charts with negative Y values, the X axis will not automatically appear at Y=0. If your value set will include negative values, I would suggest setting the Y axis maximum and minimum to the maximum and minimum values on your menu list, rather than letting Numbers decide what range to include on the chart. Place a line shape across the chart at the zero level, and choose to NOT show the X axis.
Regards,
Barry
Maybe you are looking for
-
Is there a way to make a preset that makes Auto Tone behave the way it did in the beta?
Yes, I'm probably the only person on the planet that wants this, but I liked how the Auto Tone auto adjusted the Exposure slider (ONLY!) and left all the other sliders at zero in the Lightroom 4 beta. Is there a way to write a preset that returns tha
-
Excise Base value calculated wrongly in GR
Dear experts, When preparing Bought out goods receipt in migo,excise base value is coming wrongly(not as per PO) in sometimes. If we come back from the screen without saving & then try again. That time the base value is calculating correctly. This ki
-
HELP HOOKING UP MY LINKSYS WRT100
i would like to hook my linksys wrt100rangeplus router up as my own network but we also have the fios router and apple extreme.which are in different rooms i just want to see if i can do this since every computer or anything that runs will cut out
-
Best way to transfer large datasets between actors (Actor framework)
Hi everyone I am in the planning / design phase of a larger application for which I wish to use the Actor Framework. It seems like a good "design pattern", easy for multiple developers to work on, easy to expand and easy to maintain. In this applicat
-
DVD Recordable Disc Aren't Recognized - HELP
Hello, HELP! As the title suggests DVD Recordable Disc aren't recognized by my PowerBook. Music CDs - Work DVDs (R2 and R1) - Work CD-R - Work CD-RW - Work But.. DVD+(or)-R won't work. The disc spins in the drive as if reading, then spins again. But