Using a CASE statement in 'IN' where clause clause
Hello
I have a form that users see after they connect with a few items and they type or select values based on the element type. All reports in the application use these values of PAGE 1 in where clause to filter the lines.
One of these question is "Quarter". I have a group of radio buttons on the PAGE 1 on the P1_QTR point.
I need to provide users a way to take the last 4, last 3, last 2 or current quarter and I need to dynamically build a clause WHERE the interactive report based on the selection in the form.
I am trying to use the CASE as shown below and get the syntax error.
AND QTR to (when BOX: P1_QTR = 'CURRENT' then ("T4"))
When: P1_QTR = "LAST" then ("Q3")
When: P1_QTR = 'LAST TWO' then ('Q3, "Q4")
When: P1_QTR = 'LAST THREE' then ("Q2", "Q3,' T4 ')
another ("T1", "T2", "Q3,' T4 ')
END)
How can I achieve this?
Following a simple logic, try
and QTR to
(
Select 'T4' double where: P1_QTR <> 'LAST '.
Union of all the
Select 'Q3' to double where: P1_QTR <> "in PROCESS".
Union of all the
Select "Q2" double where: P1_QTR not in ('CURRENT', 'LAST', "LAST TWO")
Union of all the
Select "Q1" double where: P1_QTR not in ('CURRENT', 'LAST', 'LAST TWO', 'THREE LATEST')
)
Tags: Database
Similar Questions
-
Tuning - using the CASE statement in the WHERE clause of the query
Hi all
My request has been changed to use a CASE statement in the WHERE clause to examine the data to some columns based on a parameter value. This modified request is made a full table and constantly running scan. Please suggest what can be done to improve its performance:
Query:
Description of the table:SELECT LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS summary_date, os.acctnum, os.avieworigin_refid, COUNT(1) cnt_articleview, SUM(NVL(autocompletedterm,0)) cnt_autocompletedterm FROM TABLE1 os WHERE os.acctnum IS NOT NULL AND os.avieworigin_refid IS NOT NULL AND os.requestdatetime IS NOT NULL AND UPPER(os.success_ind) = 'S' AND CASE WHEN Param_ValueToCheck = 'FULL' AND get_date_timestamp(os.requestdatetime) BETWEEN TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') THEN 1 WHEN Param_ValueToCheck = 'INCR' AND os.entry_createddate BETWEEN TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') THEN 1 END = 1 AND CASE WHEN Param_ValueToCheck = 'FULL' AND os.entry_CreatedDate BETWEEN TO_DATE('01-APR-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('07-JUN-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') THEN 1 WHEN Param_ValueToCheck = 'INCR' THEN 1 END = 1 GROUP BY LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))), os.acctnum,os.avieworigin_refid;
(Number of lines: approx. > amount 600 000 000)
Explain PlanName Null Type ------------------------------ -------- ------------ ARTICLEID NOT NULL NUMBER(20) USERKEY NUMBER(10) AVIEWORIGIN_REFID VARCHAR2(10) SUCCESS_IND VARCHAR2(2) ENTRY_CREATEDDATE DATE CREATED_BY VARCHAR2(10) FILENUMBER NUMBER(10) LINENUMBER NUMBER(10) ACCTNUM VARCHAR2(10) AUTOCOMPLETEDTERM NUMBER(2) REQUESTDATETIME VARCHAR2(19)
Published by: Chaitanya on June 9, 2011 02:44SQL> select * from table(dbms_xplan.display); PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Plan hash value: 2224314832 ---------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | ---------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 590 | 33040 | 2501K (1)| 08:20:15 | | | | 1 | HASH GROUP BY | | 590 | 33040 | 2501K (1)| 08:20:15 | | | | 2 | PARTITION RANGE ALL| | 590 | 33040 | 2501K (1)| 08:20:15 | 1 |1048575| |* 3 | TABLE ACCESS FULL | TABLE1 | 590 | 33040 | 2501K (1)| 08:20:15 | 1 |1048575| ---------------------------------------------------------------------------------------------------------- PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 3 - filter(UPPER("OS"."SUCCESS_IND")='S' AND CASE WHEN ('FULL'='FULL' AND "OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-04-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE(' 2011-06-07 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN 'FULL'='INCR' THEN 1 END =1 AND "OS"."REQUESTDATETIME" IS NOT NULL AND CASE WHEN ('FULL'='FULL' AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")>=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")<=TO_DATE(' 2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN ('FULL'='INCR' AND "OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE(' PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 END =1 AND "OS"."ACCTNUM" IS NOT NULL AND "OS"."AVIEWORIGIN_REFID" IS NOT NULL)
Published by: Chaitanya on June 9, 2011 02:47When it is executed individually, MERGE LOGIC 1 and LOGIC of MERGE 2 take about ten for a daterange of 30 days data.
BUT FULL is to get the scores of APR - JUN, INCR becomes partitions for MAY so not both 30 days.
Are compare us like with like? -
Case statement in a WHERE clause
Gurus,
Im trying to avoid Union of several select statements using a CASE inside a WHERE clause. When the parameter is defined as "What's new" it is advisable to use a code and for "Update Items" another condition.
Having a problem with the following... I know that BOX in WHEREs instructions are allowed only can not make it work for this one.
Points for correct and helpful answers!and case when 'New Items' = 'xxx' --p_item_status then msi.creation_date = msi.last_update_date when 'Updated Items' = 'bbb' --p_item_status then msi.creation_date != msi.last_update_date else 1=1 end;
Published by: sreese on March 27, 2012 17:51Hello
The great thing about CASE expressions, is that they allow you to use a login IF-THEN-ELSE in the clause SELECT, the ORDER BY clause or anywhere else. The WHERE clause has its own way to IF-THEN-ELSE logic, so even if you can use a CASE expression in a clause WHERRE, it usually does not help anything. You can do somehting like this:
WHERE ( :p_item_status = 'New Items' AND msi.creation_date = msi.last_update_date ) OR ( :p_item_status = 'Updated Items' AND msi.creation_date != msi.last_update_date ) OR ( :p_item_status NOT IN ( 'New Items' , 'Updated Items' ) )
This guess: p_item_status is not NULL.
If: p_item_status can be NULL, and you want to include all the lines where it is, and then change the last condition toOR ( NVL (:p_item_status, 'OK') NOT IN ( 'New Items' , 'Updated Items' ) )
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions), some values of the parameter and the expected results of these data for each value of the parameter.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using. -
A CASE statement with additional where clause
Hi all
I need assistance in which this obligation clause
Table:-balance_table
Columns:-balance_type, balance_amount, balance_month, budget_name
balance_type column had given 'Real' OR 'Budget '.
Now I am trying to extract data such as: if: entered_month is Mar-2009 then before and including Mar-2009 will show real balance sheet Date and after Mar-2009 will show budget data.
It works fine, I need to add a condition more restrict the budget name, there are several budget_name in the table for balance_type = 'Budget '.
SELECT SUM (balance_amount), balance_type, balance_month
OF balance_table
WHERE balance_type =
(CASE
WHEN balance_month < =: entered_month
THEN 'real '.
ANOTHER 'Budget '.
END
)
AND budget_name = 'BUDGET1.
Balance_type GROUP, balance_month
Stated above is erroneous because ' AND budget_name = ' BUDGET1 "clause restricts the set of data."
Please help in contrcuting where clause 1) to sort the data according to Budget/actual and 2) for specific budgets, so budget_type = Budget
Thank you
BobinThat should do it.
SELECT SUM (balance_amount), balance_type, balance_month FROM balance_table WHERE (balance_type = 'Actual' and balance_month <= :entered_month ) or (balance_type = 'Budget' and balance_month > :entered_month and budget_name = :entered_budget_name ) GROUP BY balance_type, balance_month ORDER BY 2
See you soon
Sarma. -
Case statement in a where clause clause
Hi all
This is a query that works perfectly except when: P_value don't have any value the two result Y and N should show as a result.
I tried with a statement of NVL but it gives me an error. Someone can help me.
-----------------------------------
Select
ID
CASE
WHEN (colonne_1) > (column_2)
THEN 'Y '.
ANOTHER "N".
END 'Test '.
OF tabel_1
WHERE
(CASE
WHEN (colonne_1) > (column_2)
THEN 'Y '.
ANOTHER "N".
END
) =: P_value
---------------------------------When: P_value have no any value the two result Y and N should show as a result.
It is not fair
SELECT id, CASE WHEN (column_1) > (column_2) THEN 'Y' ELSE 'N' END "Test" FROM tabel_1 WHERE (CASE WHEN (column_1) > (column_2) THEN 'Y' ELSE 'N' END = :p_value OR :p_value IS NULL)
??
-
No output for report of XML editor using CASE/DECODE in a Where Clause
Hello
I have a requirement of the company to modify an existing report that has two input parameters,
-> p_statcode (closed status) which may have values "Y" or "n".
-> p_overdue (flag late), which can have values of "Y" or "n".
The flag late is a column evaluated with O/N values and it is evaluated as follows,
The requirement of user now is that they must be a third option for setting called p_overdue ALL,ONTF_MOD_VAL(NVL ( (TRUNC (SYSDATE) - (TO_DATE (oe_order_lines.attribute18, 'DD-MON-RRRR') + TO_NUMBER (fnd_lookup_values.meaning))), 0 )) overdue_flag
which by the way the output should include records with
p_statcode is p_statcode ELSE is N AND Y OR p_overdue p_overdue is N
In other words records with raising the Y and N for flag late must be returned regardless of the value given to the closed state.
Original where clause contained in the data definition file is as follows,
My modified code is the following,WHERE Closed_Status = nvl(:p_statcode,Closed_Status) AND overdue_flag = nvl(:p_overdue,overdue_flag)
ORWHERE Closed_Status = NVL (:p_statcode, Closed_Status) AND overdue_flag = (CASE WHEN :p_overdue = 'Y' THEN 'Y' WHEN :p_overdue = 'N' THEN 'N' ELSE overdue_flag END)
Both approaches have the same problem.WHERE Closed_Status = NVL (:p_statcode, Closed_Status) AND overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag)
The output is in EXCEL format. The modified query works very well for p_overdue as Y or N but when p_overdue is passed as ALL he returned a blank EXCEL sheet with just exit report column headings.
Any help regarding, why is this the case? What's not in my approach?
Kind regards
Vishalunclear on p_overdue = ALL
P_overdue = ALL on what necessary values?try sth like
WHERE Closed_Status = NVL (:p_statcode, Closed_Status) AND ( overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag) and :p_overdue != 'ALL' or :p_overdue = 'ALL' and (overdue_flag = 'Y' or overdue_flag = 'N') )
for overdue_flag, which has more then 'Y' values of "n".
If overdue_flag that in ('Y', ' don't) thenWHERE Closed_Status = NVL (:p_statcode, Closed_Status) AND ( overdue_flag = DECODE (:p_overdue, 'Y', 'Y', 'N', 'N',overdue_flag) and :p_overdue != 'ALL' or :p_overdue = 'ALL' )
-
using a Case statement to display the values of column even as table headers
I have a database that has been set up kind of tricky, in that some tables are made up of columns that are field names and one link to another table that contain the data for these field... also names there ID displays as many lines instead of as a row of data. I would like to write a query to extract that information and display it as one line for each ID.
example: table 1
ID, name, itemresponse and itemcode, Description
Dee Jones Childrens Hospital 123 SITE location
123 dee Jones, Date of appointment next NEXTAPPT 22/04/2014
123 dee Jones was on bedrest NOSHOW reason do not show
I would like to have the display of data as a record on this same patient, instead of as 3 separate registers (with the Description column in table 1
Table 2
ID, name, place, Date of the next meeting, show no reason
123 dee Jones Childrens Hospital 22/04/2014 was the bed rest
I have included the code I worked on below my question, for me to get the desired results should I use the Case statement and it's the right way to do it below?
(SELECT
PAT.ID "PATIENT ID."
PAT. FIRST | » '|| PAT. "PATIENT FIRST NAME."
PAT. "PATIENT DOB," DATE_OF_BIRTH
DS. Date 'Date of inpatients ',.
Dai. ITEM_CODE "Item Code",
Dai. DESCRIPTION "Description."
Siad. ITEM_RESPONSE,Max (CASE WHEN dai. ITEM_CODE IS "SITE" THEN DAI. Decription
ANOTHER NULL
END) AS "name of the hospital."
Max (CASE WHEN DAI.) ITEM_CODE IS 'NEXTAPPT' THEN DAI. ITEM_Description
ANOTHER NULL
END) AS 'next Appt Date. "
Max (CASE WHEN DAI.) ITEM_CODE IS "LASTDATE" THEN DAI. Description
ANOTHER NULL
END) AS 'last visit Date.
Max (CASE WHEN DAI.) ITEM_CODE IS 'NOSHOW' THEN DAI. Description
ANOTHER NULL
END) THAT "the reason has not shown".
Of
(PAT.ID "IDENTIFYING PATIENT",
PAT. FIRST | » '|| PAT. "PATIENT FIRST NAME."
PAT. "PATIENT DOB," DATE_OF_BIRTH
DS. Date 'Date of inpatients ',.
Dai. ITEM_CODE "Item Code",
Dai. DESCRIPTION "Description."
Siad. ITEM_RESPONSEOf
dm_sessions Ds,
dm_session_assessments dsa,
DAS dm_admin_sections,
dm_session_assessment_items Siad,
Dai dm_admin_items,
Po Patient_Orders,
Inventory inv,
Patients_Table PAT
dm_admin_categories CAD
where dsa.session_Id = ds.session_Id
and PAT.ID = ds. Patient_ID
and dsa.excluded_assessment =' no
and dac.category_code = 'OPEN'and dsa.section_id = das.section_id
and das.category_id = dac.category_id
and das.section_code = 'northwest'
and dai.section_id = das.section_id
and dsai.item_id = dai.item_id
and dsai.session_assessment_Id = dsa.session_assessment_Id
and dsai.excluded =' no
- and Dai.ITEM_ID = Dsai.ITEM_ID
and Dai.ITEM_CODE IN ('SITE', 'NEXTAPPT', 'LASTDATE', 'NOSHOW')
and po.patient_ID = ds.patient_ID
and in. NDC_NO = inv. NDC_NO
and inv. TDRUG_ABBREV = in. DRUG_ABBREV
PAT.ID GROUP, PAT. FIRST | » '|| PAT. LAST, PAT. DATE_OF_BIRTH, ds. Date, dai. ITEM_CODE, dai. DESCRIPTION, Siad. ITEM_RESPONSE))Hello
DATE is not a very good name for a column. Use something like EVENT_DATE, that will not be confused with a keyword from Oracle, instead.
I don't see something like this column in the CREATE TABLE statement. He will always be the same value on all lines?
Here's a way to get the results you requested:
SELECT id
first name | ' ' || LastName AS name
Date of birth
MAX (CASE WHEN item_code = "NEXTAPPT", THEN item_response END) AS next_appointment,
MAX (CASE WHEN item_code = "LASTDATE" THEN item_response END) AS last_visit_date,
MAX (CASE WHEN item_code = "SITE" THEN item_response END) AS location
FROM mytable1
GROUP BY id, firstname, lastname, dob
;
Of course, I can't test it very well until you post INSERT statements for the sample data.
I guess that 2 or more lines of the entry have the same id, then they will necessarily be first name last name, the name and date of birth, too. No doubt they are standardized in your actual tables.
-
Schema export multile using the case statement
Hello
I want several export schema using case statement.
provable I 4 schema test1, test2, test3 test4 for the scheme I created scripts for each of them either 4 scripts but I want only a scripts instead of 4 scripts. Please suggest how to write shell scripts using a case statement (via a parameter name or the schema).
example of diagram of TEST1.
expdp "" system/redhat as sysdba' "dumpfile directory = TEST1.dmp = DUMP_DIR = TEST1.log patterns = TEST1 logfile logfile = TEST1_Export.log
is it possible if you use under case statement (via the name of parameter/schema)
as case 1: TEST1
2: TEST2
3: TEST3
4: TEST4
If I pass the value as TEST1, and TEST1 schema export is made.No, it's easier.
In addition, you can only get the number and then use TEST$ {export_schema} instead.
But in any case you don't have no need 'breaks '. -
case in PL/SQL where clause statement
- Hello
- I have a research procedure where the user can search on the city, street, zip code.
- I need meet the 6 different combinations as I don't know what value the user will pass.
- It should be checked if the user passes the value or not, and then look on values passed.
- But the procedure below is out.it the slightest mistake can be transformed with if-then-else, but case statement seems much cleaner in the code.
- procedure searchaddress (pc_town IN SEARCHADDRESS. CITY % TYPE,
pc_street IN SEARCHADDRESS. TYPICAL STREET %,
pc_postcode IN SEARCHADDRESS. POSTCODE % TYPE,
pResultSet to ref_cursor) as
Start
Open the pResultset for
Select searchaddress_pk from searchaddress
where
case
When pc_town is null then ((street = pc_street) and (ZipCode = pc_postcode))
When pc_street is null then ((town = pc_town) and (ZipCode = pc_postcode))
When pc_postcode is null then ((town = pc_town) and (street = pc_street))
When pc_town is null and pc_street is null then (postal code = pc_postcode)
When pc_street is null and pc_postcode is null then (city = pc_town)
When pc_town is null and pc_postcode is null then (street = pc_street)
end
end searchaddress;
Thank you
CenterB
A basic concept that is important to understand - sliders aren't 'sets of results' (sets of data in memory). A cursor is a series of executable steps (see plans run to cursor). It's like a program. An extraction run the program and output data. In general, which is repeated until the cursor (aka program) is no longer found the corresponding lines.
A ref cursor is a pointer or a handle for a such slider, passed to a caller, allowing the appellant to interface directly with this slider/program.
The slider more effective to create a search would be one without superfluous code and predicates and filters. Consider the following approach - a beefier PL/SQL procedure, do not try and play little tricks with SQL predicates in an attempt to create one (and probably not optimal) SQL.
(not tested/compiled code)
create or replace procedure SearchAddress( town IN SEARCHADDRESS.TOWN%TYPE, street IN SEARCHADDRESS.STREET%TYPE, postcode IN SEARCHADDRESS.POSTCODE%TYPE, refCur out ref_cursor ) is curHandle integer; res integer; searchSQL varchar2(1000); begin -- create base query searchSQL := 'select searchaddress_pk from searchaddress where 1 = 1 '; -- add dynamic predicates as needed if town is not null then searchSQL := searchSQL || 'and town = :town'; end if; if street is not null then searchSQL := searchSQL || ' and street = :street'; end if; if postcode is not null then searchSQL := searchSQL || ' and postcode = :postcode'; end if; -- create a DBMS_SQL cursor curHandle := DBMS_SQL.open_cursor; DBMS_SQL.parse( curHandle, searchSQL, DBMS_SQL.NATIVE ); -- bind the dynamic bind variables added as predicate values if town is not null then DBMS_SQL.Bind_Variable( curHandle, 'town', town ); end if; if street is not null then DBMS_SQL.Bind_Variable( curHandle, 'street', street ); end if; if postcode is not null then DBMS_SQL.Bind_Variable( curHandle, 'postcode', postcode ); end if; -- execute cursor (to create the cursor program) and pass it back as a ref cursor res := DBMS_SQL.Execute( curHandle ); refCur := DBMS_SQL.To_RefCursor( curHandle ); end;
-
Case instructions within a Where clause clause
Hello group,
I know this has been asked several times, but I do not enter simply to a tuition assistance box in a WHERE clause. So I need help:
My current WHERE the clause reads:
A16. FULL_DATE between (SELECT (TRUNC (SysDate - 8)) From Dual) and (select (TRUNC (SysDate - 2)) double)
However, I need to 'automate' a bit, based on the current time/day of the month. I need my instruction box to say:
(Case when to_char (sysdate-3, 'mm') <>to_char (sysdate, 'mm')
then the a16. FULL_DATE (between SELECT (trunc (ADD_MONTHS ((LAST_DAY(SysDate-3)),-1)+1) and (SELECT (add_months (trunc(SysDate-2)-1)) of double)))
Of another a16. FULL_DATE between (SELECT trunc (ADD_MONTHS ((LAST_DAY (SysDate)),-1)+1) From Dual) and (select (TRUNC (SysDate - 2)) From Dual)
However, I have an error on "Else". Can someone explain what is the problem and how to fix it? I tried both 'then' and 'Else' syntax and both will run individually. So I'm quite sure that he does not like my CASE statement in general.
In advance, thank you for your help.
Don
I can't tell what your business logic, so here's a simple example of an instruction box in the where clause:
SQL > select *.
2 double
3 where dummy = case when extracted (sysdate months) = 9 then 'W '.
4 Once extracted (sysdate months) = 10 then 'X '.
When 5 extract (month from sysdate) = 11 then 'Y '.
6 else 'Z'
7 end
8;D
-
X -
Use the CASE statement in a query of LOV
Hello
I wrote a select statement to be used in my list of values query, and it works fine when I run with SQL Developer. But when I put it in the LOV I get the LOV query is invalid error message. Here's the query I use:
If the CASE statement is the source of the problem?select case when nt.COMMON_NAME is not null then nt.COMMON_NAME || ' (' || nt.TAXON_NAME || ')' else nt.TAXON_NAME end display_species ,case when nt.COMMON_NAME is not null then nt.COMMON_NAME || ' (' || nt.TAXON_NAME || ')' else nt.TAXON_NAME end return_species FROM NBN_TAXON nt WHERE lower(nt.INPUT_CATEGORY) = decode(lower(:P312_TAXON_GROUP_ADD), 'fish', 'fishes', lower(:P312_TAXON_GROUP_ADD)) order by 1;
Hello
Try to remove the colon semi at the end.
See you soon
Ben
-
HelloHow can I convert a code for the below sql case statement:
If)
(length of (tmp_co_orig_val) < = 0 OR tmp_co_orig_val < = 0 OR tmp_co_orig_val == 1 OR tmp_co_orig_val > = 9999999)
OR
((tmp_co_orig_val == 999999 AND (length of (tmp_rcr_orgn_ltv_rt) < = 0 OR tmp_rcr_orgn_ltv_rt < tmp_rcr_orgn_ltv_rt > 1.3 GOLD 0.15)))
Start
tmp_collatvalue = «»
tmp_msg_cd = 115
end
Is the case statement below that I wrote is correct. I don't have an environment now to test. Please advice.
BOX WHEN (CHAR_LENGTH (tmp_co_orig_val) < = 0 OR tmp_co_orig_val < 0 OR tmp_co_orig_val = 1 OR tmp_co_orig_val = > = 9999999)
OR (tmp_co_orig_val = 999999 AND (CHAR_LENGTH (tmp_rcr_orgn_ltv_rt) < = 0 OR tmp_rcr_orgn_ltv_rt < tmp_rcr_orgn_ltv_rt > 1.3 GOLD 0.15))
THEN tmp_collatvalue IS NULL AND tmp_msg_cd = 115
END
Hello
937454 wrote:
Thanks Frank. Really helps. But I have to write a sql statement
But can you also specify, if I made a mistake in my code, or it's ok.
There are no CASES reported in Oracle SQL.
Oracle SQL has BOX expressions, but they only return a single value. You cannot set 2 columns in the same expression BOX.
Perhaps the best thing to do in pure SQL for you is to write a CASE expression, very similar to the CASE statement above, in a subquery and use the results of this in 2 separate expressions of BOX (very simple) in a Super application.
-
Help: How to use the Case statement in the ODI11g Interface?
Hello
My basic source I get 'Year' values and I want that these values result code in the interface and after translation want to push on the target system.
Example:
Database source, I get value for
Year
2010
2011
2012
When I get the year 2010 I want to change the value in "FY10".
When I get year 2011 I want to change the value in "FY11.
and even for the year 2012 to "FY12.
I've tried to make the Case statement, but had no success.
I don't want to create the lookup table in the source system.
Any help in this matter.
Thank you
Concerning
Sher
Published by: Sher Ullah Baig on August 26, 2012 17:52CASE
WHEN source_column = '2010' THEN 'FY10.
WHEN source_column = '2011' and THEN 'FY11.
WHEN source_column = '2012' and THEN 'FY12.
END -
Using the Case statement in Where clause with operator
Hi all
I'm doing the following work (this is just a simple version of what I'll eventually need):
Sorry, I forgot how to use the code tags...
and li. MAJOR_ACCT in case
When: prompt = 'Energy' then ('9320906 ', ' 9321471')
end
Problem is that I get a missing closing parenthesis error.
Wouldn't - that evaluate against a value(as below) it works fine:
and li. MAJOR_ACCT in case
When: prompt = 'Energy' then ('9320906')
end
Any thoughts? Is it possible to use a box (or decode) in an In clause with multiple values? I tried to use decode as well and get the same results.
Thank you.
Darren.What:
and ( case when :prompt = 'Energy' and li.MAJOR_ACCT in ('9320906', '9321471') then 1 when :prompt = 'Vehicle' and li.MAJOR_ACCT in ('9812180', '9812320') then 1 when :prompt = 'Meals' and li.MAJOR_ACCT in ('983120', '983452') then 1 end ) = 1
-
Need help with CASE When statement in a Where Clause
So I have a SQL (simplified for this forum)
Select t1.*
from table1, table2 t2 t1
where t1.field1 = t2.field1
and when t1.field2 is null then trunc (sysdate) < = trunc (t1.date1 + 17)
of another trunc (sydate) > = end of trunc (t2.date2 + t2.date3)
I end up getting an error ORA-00905: lack of keyword
I'm sure that I just got something here involved.You can not make the comparison within the statement underlying case like this. Assuming you have appropriate data types, something like this should work
Select t1.* from table1 t1, table2 t2 where t1.field1 = t2.field1 and ((t1.field2 is null and trunc(sysdate) <= trunc(t1.date1 + 17)) or trunc(sydate) > = trunc(t2.date2 + t2.date3))
John
Maybe you are looking for
-
My macpro 2010 very rarely gives the boot chime on startup. He, however, successfully boots 100% of the time, but very slowly. I can even reset the pram without hear the boot chime. This is an indication of some sort of self test problem?
-
Photosmart C5180 - impossible to remove from the queue of the printer
Hello I am trying to print something, but I can't delete the first document in the queue (what's more, I want to print). It is frozen on the "remove" status, but nothing happens. I tried restarting both the printer and laptop, but still nothing. Help
-
LOS DRIVERS OF HP LASER JET 2100 C4170A USGH240855 UNA
BUSCO una Patrick hewlett packard HP 2100 series controllers los. C4170A USGH240855. Los puedo bajar where?
-
results for "WindowsUpdate unknown error_80010108" "WindowsUpdate_dt000"
Supplementary question: none know away around the my problem I have with my Palm Z22? Windows 7 64 bit does not all drivers for my Palm. It only works with the 32-bit Windows 7 and Vista.
-
When I type p on my laptop it will appear * how do I solve this problem
When I type p on my laptop it will appear * how do I solve this problem