How to divide the SQL resultset based on the data as scenarios?
Hi,
I need to develop a query which needs to be divided into scenarios
Ex:
Scenario 1: If a product is sold in US and billed in UK
Scenario 2: If a product is sold in UK and billed in US
Scenario 3: If a product is sold and billed in US
Scenario 4: If a product is sold and billed in UK
Based on 1 SQL result how can I divide and provide users based on the scenarios?
Ex: Result should display all the data saying this result set is under scenario 1 etc.,
Please advice
Thanks,
user12048986
Hi,
You can use a CASE expression to categorize each row:
CASE sold_country || ' ' || billed_country
WHEN 'US UK' THEN 1
WHEN 'UK US' THEN 2
WHEN 'US US' THEN 3
WHEN 'UK UK' THEN 4
END AS scenario_numIf either sold_country or billed_country is anything except 'UK' or 'US', then the expression above returns NULL.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data.
Similar Messages
-
How to exit from SQL*Plus based on the return value of a SQL select stment?
Hi
I have a SQL script executed from SQL*Plus. I would like to know if SQL*Plus
supports any kind of branching or exiting from script execution based on a
returned value of a SQL select statement. I am on 9i.
Regards,
Tamas Szecsyin sqlplus, you have whenever
ex:
whenever sqlerror exit failure
insert into ...
-- if this fails, then you will be out
insert into ...
-- if this fails, then you will be out
whenever sqlerror continue
insert into ...
-- if this fails, this continues
insert into ...and you have PL/SQL
declare x number;
begin
select count(*) into x from emp;
if (x=14) then null; end if;
end;
/note that you can mix those in some case
-- exit if there is no row in emp
whenever sqlerror exit 1
var dummy number
exec select count(*) into :dummy from emp having count(*)!=0 -
How to get the SQL queries based on SQL_ID.
Hi Experts,
I want to get the SQL queries based on SQL_ID.
I have tried the following query,but I am not getting full query.
[code]SET linesize 132 pagesize 999
column sql_fulltext format a60 word_wrap
break on sql_text skip 1
SELECT REPLACE (TRANSLATE (sql_text, '0123456789', '999999999'), '9', ''),sql_id
FROM dba_hist_sqltext s
WHERE s.sql_id = '7tvurftg8zryb';[/code]
One of my friend said use grid to get full query text.
Can you please help me how to use grid ,else any other method to get the full query based on SQL_ID.
Please help me.
Thanks in advance.You have these many options to set, if sql_text is really huge. But better use a tool(TOAD) as it's really helpful and easy to use instead! (See my previous comment).
column sql_text format A10000
set echo off
set head off
set feed off
set verify off
set termout off
set lines 10000
set long 1000000
set trimspool on
set pages 0
Thanks! -
How to dynamic to add +/- 10 to the y axis based on returned data value max/min
Hi,
We have two ways to extract/present the data/chart. One is using SQL Reporting and one is using EXCEL. However, we hardcoded the max/min value on y asix to various data set so the chart looks good. However, SQL reporting seems using auto on the y asix so
when some values are 0, it just overlapped with the x-asix as dipicture below (left hand side is SQL reporting and right hand size is EXCEL)
Please advise how to add an +/- interval on the y asix based on the max/min returned data value (e.g if the max returned value is 100 and min returned value is 0, the max value on y asix would be 110 and min value of y asix would be -10)
ThanksHi kkcci88888,
According to your description, there is a chart in the report, you want to set vertical axis range and interval dynamically. For example, if the max value of the column is 100 and min value is 0, the max value on y axis would be 110 and min value of y axis
would be -10. If that is the case, please refer to the following steps:
1. In design surface, right-click Y axis and open Vertical Axis Properties dialog box.
2. In Axis Options pane, click (fx) button next to Minimum and type the expression like below:
=Min(Fields!num.Value)- 10
3. Click (fx) button next to Maximum and type the expression like below:
=Max(Fields!num.Value)+ 10
4. Set Interval to 10, Interval type to Number.
The following screenshots are for your reference:
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu -
How to enable/disable the input fields based on the data entered in the web dynpro application abap? If the user enters data in one input field then only the next input field should be enabled else it should be in disabled state. Please guide.
Hi,
Try this code.
First create a attribute with the name readonly of type wdy_boolean and bind it read_only property of input field of which is you want to enable or disable.
Next go to Init method.
Set the readonly value as 'X'.
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_visible TYPE wd_this->element_context-visible.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* @TODO handle not set lead selection
IF lo_el_context IS INITIAL.
ENDIF.
* @TODO fill attribute
* lv_visible = 1.
* set single attribute
lo_el_context->set_attribute(
name = `READONLY`
value = 'X').
After that Go to the Action ENTER.
First read the input field ( first input field, which is value entered field) , next give a condition
if input value is not initial then set the readonly value is ' '.
DATA lo_nd_input TYPE REF TO if_wd_context_node.
DATA lo_el_input TYPE REF TO if_wd_context_element.
DATA ls_input TYPE wd_this->element_input.
DATA lv_vbeln TYPE wd_this->element_input-vbeln.
* navigate from <CONTEXT> to <INPUT> via lead selection
lo_nd_input = wd_context->get_child_node( name = wd_this->wdctx_input ).
* @TODO handle non existant child
* IF lo_nd_input IS INITIAL.
* ENDIF.
* get element via lead selection
lo_el_input = lo_nd_input->get_element( ).
* @TODO handle not set lead selection
IF lo_el_input IS INITIAL.
ENDIF.
* get single attribute
lo_el_input->get_attribute(
EXPORTING
name = `VBELN`
IMPORTING
value = lv_vbeln ).
if lv_vbeln IS not INITIAL.
DATA lo_el_context TYPE REF TO if_wd_context_element.
DATA ls_context TYPE wd_this->element_context.
DATA lv_visible TYPE wd_this->element_context-visible.
* get element via lead selection
lo_el_context = wd_context->get_element( ).
* @TODO handle not set lead selection
IF lo_el_context IS INITIAL.
ENDIF.
* @TODO fill attribute
* lv_visible = 1.
* set single attribute
lo_el_context->set_attribute(
name = `READONLY`
value = ' ' ). -
How to identify the SQLs which are using the tables and new columns
Hi
I m using oracle 10G Database in windows. Developers have added some columns in some of the database tables and were asking to check whether there is some impact on performance or not. I have not done this performance tuning before. Kindly help me how to proceed further.
How to obtain the sqls which are touching the tables and the new columns? It would be really great if you can help me with this.
ThanksYou can try to use DBA_DEPENDENCIES to get PL/SQL objects using tables: http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/statviews_1041.htm#i1576452.
However if SQL code is not stored in database in a trigger, a procedure, a function, a package or a view, it is impossible to retrieve all SQL code referencing some table from database dictionary: for this you would have to analyze application source code. -
SQL Query to retrieve the All records based on the Max Dates.
Hello all,
I am trying to retrieve the newest record based on the date field ( nextDate ).
Currently there are only 4 records in the MC_Maintenance table and two in the Machine table.
Machine table
MC_id EquipID
1 0227
MC_id EquipID
2 0228
MC_Maintenance table
Maint_id MC_id Next_maint
1 2 08/25/2010
2 2 07/01/2010
3 1 06/11/2010
4 1 07/11/2010
What I am trying to accomplish is,
list the two machines from the Machine table with the MAX(Next_maint) controlling the MC_Maintenance output list
These are the records that I would like to Display.
Maint_id MC_id Next_maint
1 2 08/25/2010
4 1 07/11/2010
Below is the SQL Query
SELECT
MC.MC_ID as ID,
MC.complete_Date as completed,
MC.next_maint as nextDate,
MC.maint_notes as Notes,
MC.facility as Facility,
M.EquipId,
M.name as name,
M.SerialNumber as SN,
M.dept as dept,
M.Freq as freq
From MC_Maintenance MC, Machine M
where MC.MC_ID = M.MC_ID
' USING MAX(nextDate )
Any ideas would help.
TJI would have thought that was a simple group by problem?
SELECT M.EquipID, MC.MC_ID, Max(MC.next_maint)
FROM MC_Maintenance MC INNER JOIN Machine M ON MC.MC_ID = M.MC_ID
GROUP BY M.EquipID, MC.MC_ID -
Why is the folder strukture based on the import date, and not on the Creation date? How can i setting this?
What folder structure?
If you're referring to how Aperture stores the originals in a managed library then the answer is you can't change it.
If having the originals stored in a specific file structure is important to you you will need to switch to a referenced original setup. -
How to configuration of pricing procedure based on the Region
Hi,
please help me how to configuration of pricing procedure based on the Region in the roll out project.
Thanks
mustafaWhat I proposed to do was,
a. Create routes like 0 day route, 1 Day route, 2 day route etc.
b. Route determination is based on the Shipping condition of the customer. Put in the shipping condition for the customer as 00 - immediate delivery. 01 - By Truck, 02 - By Rail, 03 - Ship etc
c. Now, put in your route determination in such a way that routes change in the sales order with shipping condition (SC). Like, if the shipping condition is set to 00, then 0 day route comes up. Meaning immediate delivery, if SC is 01, then your normal route by truck picks up. etc.
When the sales order is manually created, you know the time of creation. As route is one of the criteria, the material confirmation happens based on number of days you put in the route to reach the destination. Now that you have the material available for today's delivery, the delivery program can be run to create it, or it can be manually created.
Now, when you configure the route you have to specify 'Transit duration in calendar days'.
When you have the sales order created electronically (say thru EDI), then, you may have to ask them to send in shipping condition. Else, you have to modify the function module Idoc_input_orders in such a way that if the sales order creation time is < 12 PM, then put shipping condition as 00, else copy what ever is there in the customer.
If you do not want to check the time manually when the user creates the sales order, then you may have to use the user exit MV45AFZZ (and I think you can use Save_order_prepare) to check the time and change the shipping condition. By this you will avoid extra coding in Idoc_input_orders and also need not bother if the user changed the route or not.
Hope my explanation helps.
Regards,
Mukund S -
How to get the pricing hierarchy based on the delivery date for sales order
Hi,
How to get the pricing hierarchy based on the delivery date for sales order other than system date.
My requirement is to get the Pricing hierarchy based on the delivery date other than system date.
Waiting for kind response.
Best Regards,
BDPHI Sai,
please refer teh document already how to write FM based extration on generic extractors.
and here the logic to find the latest records values:-
-> get the data in an internal table
->Sort the internal table data based from date descending
-> Using READ statement , we can read the first record of the table which is nothign but your latest record.
Regards.
Sakthi -
How can I use SQL to check if the receipt is accounted?
Dear all:
How can I use SQL to check if the AR receipt is accounted ? Because there is so many receipts to check, I cannot open it to see the detail one by one.
My environment is :11.5.9
database : Oracle 9.2.0.8Duplicate post.
How can I use SQL to check if the receipt is accounted?
Re: How can I use SQL to check if the receipt is accounted? -
How to determine the hardware requirements based on the Services' payload
hello,Guys
i am wondering if i can calculate the hardware requirements based on the services' payload ?
what factors should i consider when to determine the hardware requirements?
is there any documents related to my questions? ;)
Thanks
Regards
WenPayload size is not the only factor while determining size of the system (h/w). You need to consider number of services, nature of services (sync/async), payload size, frequency of messages (load), peak load value, security constraints, performance requirements etc..
You may contact your local Oracle Sales Representative/ Oracle Support to get help in determining size of the system. They will provide you a sizing questionarre and on the basis of that they may suggest sizing as well (Oracle has an internal tool for proposing sizing)
Regards,
Anuj -
How can I find MAC address based on the serial number of a missing IpodTouch 4th Gen?
My Ipod touch 4th Generation is lost. If I can find the MAC address, the Univeristy can help locate the device. I have the serial number, is there any way I can find the MAC address based on the serial number? I did not install a third party app on the IPod to help find it and it is not registered on iCloud, but I used it on iCloud. Any ideas are greatly appreciated.
Did you turn on FindMyiPd is Settings>iCloud and is the iPod connected to wifi? That is all that is needed for for Apple FindMyiPhone
Maybe Apple can find the MAC address
Apple - Support - iPod touch - Contact Us
Your question has been asked in the past but no one has responded if Apple could actually help -
Presentation Variable in the SQL default section in the dashboard prompt
Hi Gurus,
I have two prompts and two go buttons. First Go button is used to populate pv_category1 presentation variable.
category_column --> pv_category1--> 1st Prompt
Product_Column --> pv_product2 --> 2nd Prompt
I want to set the default for the 2nd Prompt depending on the 1st Prompt ( Category) chosen by the user.
In the SQL default --> i have typed in the below Query.
*Select TableName.Product_Column from Subject_Area where category_column = '@{pv_category1}'*
The Problem is that i dont get any default value for 2nd Prompt after choosing the First prompt and hitting the GO Button.
If i hardcode the value in @{pv_category1} ...
for eg
Select TableName.Product_Column from Subject_Area where category_column = 'Incidents' i get the corresponding value as default.
But i want this 2nd prompt (product) to dyamically default depending on the 1st prompt (category) chosen by the user.
I am using OBIEE 10.1.3.4 and i have googled a lot on this topic...
can we not use Presentation variable in the SQL default section of the Dashboard Prompt?
Any help in this regard would be highly appreciated.
Thanks
AshishThanks for the Quick Reply.
But the functionality that i want to achieve is the default value in the 2nd column (out of many values for 2nd column) based on the 1st column chosen by the USER. for eg we have two columns in our database ie category and Product.. Data goes like this
category ProductName
Incidents --- A
Incidents --- B
Incidents --- C
Changes --- D
Changes --- E
Projects --- M
Projects --- N
Projects --- O
Projects --- P
If the User chooses Incidents in the first prompt then the default in the 2nd prompt should be B ( out of A,B,C Values available in the 2nd prompt)....
Checking the constraint checkbox doesnt solve the default problem...
Thanks
Ashish -
Calculate Avg for the given months based on the no. of days in months
Dear Experts
I have a report in which there is a characterictic claenderyr/month.The Input paramter is claenderyr/month which is restricted by a variable of type interval. i mean user will enter calenderyr/month as interval say 012010 to 06.2010. Now I have to calculate Avg sale Qty for the given months based on the no. of days for the given range of months. How I can achieve this in BW Query. Pl. advice
Dinesh SharmaHi,
Create formula for the sales qty.
maintain the exception aggregation as average based on calday
Best Regards,
M.H.REDDY
Maybe you are looking for
-
Embedded JMS/OC4J issue while running an application in Jdeveloper 10.1.3.2
Hi, I am facing an issue while running an application on my laptop.I downloaded Jdeveloper 10.1.3.2.Installed Jheadstart along with that. Created a new application specified in HR demo.When I run the application I get following messages,After that it
-
Icon for customer field (field group)
Hello! We have a need to follow-up one indicator through a customer field thanks to icon (like severities). Do you know if it's possible to manage that with the field groups for customer field (I couldn't achieve that yet), or if we have to develop a
-
Transferring music from a shuffle to a touch
Hi, I have a shuffle. My wife gave me a touch for Christmas. Is there any way to transfer the music on my shuffle to my touch? Thanks, Evan
-
Operating system VERSION incompatability while installing SAP ECC 6.0 SR3
<h3>what is the dump of M.S. SQL SERVER required for installing SAP ECC 6.0 SR3 ABAP system on WINDOWS SERVER 2008 R2 ENTERPRIZE 6.1 VERSION.</h3> we installed the MS sql version: 10.50.1702 (dump number 51039339) on our Operating system version was
-
Reader 11 doesn't like LiveScribe files
Trying to open any LiveScribe pdf file with Adobe Reader 11.0.02 in Safari 5.0.5 gives a message that the file may contain malicious content, and that Reader must close. Upon acknowledging the message, Safari itself then closes. The LiveScribe file