Query to Get next Highest Value for the given value passed
Hello Gurus
i want help with a query that would get me the next highest value from a table for a given value passed. Let say these are the values in col of a table
col
6000
5000
4000
3000
2000
1000
if i pass 2000 then the output should be 3000 or if i pass 4000 then query should result 5000. Please help
May be this:
WITH t AS (SELECT 6000 val FROM DUAL
UNION ALL
SELECT 5000 FROM DUAL
UNION ALL
SELECT 4000 FROM DUAL
UNION ALL
SELECT 3000 FROM DUAL
UNION ALL
SELECT 2000 FROM DUAL
UNION ALL
SELECT 1000 FROM DUAL)
SELECT min(val)
FROM t
WHERE val > &YourVal
Similar Messages
-
Get Nexr working day for the given calendar id
Hello,
My requirenment is I have a date.If that date falls on friday then I have to get the next working day date i.e.Monday for the given Calender iDDATA:wk_dat TYPE scal-indicator.
PARAMETERS:pa_dat TYPE sy-datum.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
date = pa_dat
IMPORTING
day = wk_dat.
CHECK wk_dat = 5.
pa_dat = pa_dat + 3.
WRITE pa_dat.
here if u want to get the next working day
Use FM DATE_CHECK_WORKINGDAY after the check statement.
add the date until u find a working day. -
Displaying blank value for the Rounding Value field in MM03 transaction
Hello All,
We are using BDC to create a material master record.Some users are not loading the rouding value in the MRP1 screen. The rounding value is stored in the MARC table which has the data type as QUAN. Thus when there is no value being passed it implicitly converts the blank value to 0.00. The users do not want the rounding value to be displayed as 0 when they view the material record using mm03. Kindly let me know if there is any way to display the rounding value as blank if no value is present.
Thanks in Advance.
Regards,
Avinash Sai N SHai siddharth,
I have enabled the BADi HRPBSIN_ADDITIONAL_CHECKS to do validations for loans. Can u pls explain is there any FM or wat can be used to set default value for the field in portal.
Pls give some suggestions,
thnaks,
Nalla B. -
Query to get batch GLBATCH name for the invoices of AP and AR
Please provide a query to get GLBatch name for an invoice of AR and AR.
From one cursor iam getting invoice number and invoiceID of AP and AR.
I have written query but it is taking much time
select distinct gjb.NAME
from gl_je_headers gjh,
gl_je_lines gjl,
gl_je_batches gjb
where gjl.REFERENCE_2=to_char(:p_invoiceid)
and gjh.JE_HEADER_ID=gjl.JE_HEADER_ID
and gjh.JE_BATCH_ID=gjb.JE_BATCH_ID
so iam getting performance problem.
Please suggest if iam wrong.
Waiting for your valuable suggestion.
Thanks
ganeshHi,
the version of Oracle E-Business Suite is R12
and ORacle Database IS 11I
Thanks & Regards
ganesh -
Who to get Actual Shipment Date for the Sales Order
Dear All,
How to Get Actual Shipment Date for the given sales order.
REgards
sudheerHai,
If you want the actual shipment date of an order call the function module RV_ORDER_FLOW_INFORMATION and pass the order number as vbeln in the structure COMWA.select the values from the return table which corresponds to 'J' type which are delivery and get thedate.
THis will give the actual delivery date (if created).
Oher way is to look for vbeln in table LIPS using VGBEL = order number as the selection criteria.
Cheers,
Sandeep -
Selecting last value for a given date
I've read some of the other threads on the this tope, but can't find a resolution.
My query is supposed to get the last values for the given two days (start date and end date) and I return the difference between the two values. The query as it is only works for days where there is an entry for 12:00 pm. On some days, it will therefore return nothing. But I'm not sure how to get it to choose the last value for the given day and still remain a fast query.
Here is a sample of the query with dates that return a result.
SELECT max_query.sgnl_id as sgnl, max_query.max_val - min_query.min_val result_val
FROM
(SELECT t1.sgnl_id, t2.smpl_dte, t1.pv_id,
MAX(t2.integ_since_val) AS max_val
FROM diag.blm_acct t2, diag.pv_sgnl_id_assc t1
WHERE t2.smpl_dte = TO_DATE ('11/15/2008 12:00:00 PM', 'MM-DD-YYYY HH:MI:SS AM')
AND t1.pv_id = t2.pv_id
AND t2.pv_id IN
(SELECT pv_id
FROM diag.pv_sgnl_id_assc
WHERE sgnl_id IN
(SELECT sgnl_id
FROM diag.series_sgnl_rec_asgn
WHERE series_id = 'Series5'
GROUP BY t1.sgnl_id, t2.smpl_dte, t1.pv_id
) max_query ,
(SELECT pv_id,
MAX(integ_since_val) AS min_val
FROM diag.blm_acct
WHERE smpl_dte = TO_DATE ('11/10/2008 12:00:00 PM', 'MM-DD-YYYY HH:MI:SS AM')
AND pv_id IN
(SELECT pv_id
FROM diag.pv_sgnl_id_assc
WHERE sgnl_id IN
(SELECT sgnl_id
FROM diag.series_sgnl_rec_asgn
WHERE series_id = 'Series5'
GROUP BY pv_id
) min_query WHERE max_query.pv_id = min_query.pv_id
ORDER BY max_query.sgnl_idThe data set in the table is quite large, but the above query returns only 49 results (one for each signal in 'Series5').
I tried the following statement by itself to get the last value, but it takes quite a long time to execute (increased the overall query time from 1 sec to 400+ sec when used in the query above):
SELECT DISTINCT trunc(smpl_dte) as the_day,
first_value(integ_since_val) over (partition by trunc(smpl_dte) order by smpl_dte desc) as last_val_per_day
FROM diag.blm_acct WHERE pv_id = 3 and trunc(smpl_dte) = to_date('05/18/2008', 'MM-DD-YYYY ')Any thoughts?Well here is an example of the output I'm trying to generate:
SGNL RESULT_VAL
CCL_Diag:BLM00:Slow60PulsesTotalLoss 52.843439255
CCL_Diag:BLM101:Slow60PulsesTotalLoss 55.7883452511etc...
Here is the table structure:
describe diag.blm_acct;
Name Null Type
BLM_ACCT_ID NOT NULL NUMBER(12)
PV_ID NOT NULL NUMBER(38)
SMPL_DTE NOT NULL DATE
INTEG_OVER_VAL BINARY_DOUBLE()
INTEG_SINCE_VAL BINARY_DOUBLE()
INTEG_TYPE_ID NUMBER(3)
describe diag.PV_SGNL_ID_ASSC
Name Null Type
PV_ID NOT NULL NUMBER(38)
SGNL_ID NOT NULL VARCHAR2(75)
describe diag.SERIES_SGNL_REC_ASGN
Name Null Type
SERIES_ID NOT NULL VARCHAR2(50)
SGNL_ID NOT NULL VARCHAR2(75)
DISP_ORD_NBR NUMBER The main problem I'm having is how to replace this line of code:
WHERE t2.smpl_dte = TO_DATE ('11/15/2008 12:00:00 PM', 'MM-DD-YYYY HH:MI:SS AM')with something that will get the last value (integ_since_val) in the diag.blm_acct table for the 11/15 date.
Edited by: Solerous on Feb 18, 2009 11:32 AM - I figured out how to output the table data -
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 -
Not getting Selection(Prompt) option for the WebI Query.
Hello Experts,
I built WebI query for the custom query of SAP BI.I am not getting an selection or prompt for the WebI Query even though there is a selection in BI Query.If i develop WebI report for the standard query of the Bex i am getting selction options.
Please suggest how can i do this.
Thanks in Advance,
Shiva Kumar G.CHi Shiva,
Where in the Query Designer are the selections defined?
Selections defined under Characteristic Restrictions should show up when you run the webi report.
Additional selections created under Default Values won't show running a webi report (that is just an additional filter on the data retrieved from the data warehouse).
Regards,
Harry -
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 can I reduce the selection for the characteristics value in a BW query
Good morning,
I need to find out how I can reduce the selection for the characteristics values in a BW query.
In a BW query I have a characteristic "Due month".
The characteristic values shown in the query are from 01.2001->03.2007. I would like to reduce it to the last 2 years,in the query view, without deleting the data for the other years in the cube.
Do you know how this can be done?
Thank you in advance for your feedback.
Kind regards,
Linda Verding
Staff Consultant - CSChi,
First thing you have to do is check the report how the data is being restricted only to those months.
1) one it can be variable in which the code is written for that to populate for last few years.
or else it must have been hardcoded for these months.
Go into your report and underneath the characteristicsCALMONTH there must be an variable or hardcoding.
You need to change this here in the report.
You dont have to delete anything there.
Regards, Siva -
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 -
Cannot read the next data row for the data set
Hi,
My report runs fine when I view in VS, data shows fine when I run the query in the data window, but when I publish it to the server, I get the above error. I am running SQL server 2005 RTM and I have re-deployed the entire solution.
Any ideas?Hi All,
Upon investigation found that there was an issue with converting varchar value to datatime datatype in Stored Procedure and that is why report was throwing error.
I ran same report in BIDS and got clear error message
An error has occurred during report processing. (rsProcessingAborted)
Cannot read the next data row for the dataset xxx. (rsErrorReadingNextDataRow)
The conversion of a varchar datatype to a datetime datatype resulted in an out-of-range value
Once I corrected this, It is working fine.
Thanks Shiven:) If Answer is Helpful, Please Vote -
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.
Maybe you are looking for
-
Splitting a library does not remove the folder I moved from the original library. I exported a folder of 3000 images from the original library to a new library. The new libraryb was created alright, but the folder and the 3000 images remain in the
-
IWeb version 3.0.4 & adsense
What is the correct code to replace the Google Adsense Widget which USED to work beautifully? I want to stay with the "live ad" sizes already on my webpage but these are now blank on publication. I apologize if I am asking a stupid question, but I re
-
Can't Create new BLANK Library in iTunes 11
I haven't seen this mentioned anywhere. Since iTunes 11, I can no longer create a new BLANK library; without in seconds it begins to fill up with songs from my main library. With iTunes 10.7 I could create a new BLANK library and then fill it wit
-
Hello All Engineers, I have attached a VI with this post. Here in this VI i have two systems data coming from the field, getting the single value from each system in every second. I want as a result 2 waveform in the output chart but i am getting onl
-
Case #0184579519 not resolved. How do you intend to fix my situation for a product i have purchased?