select empno,ename,deptno,employee_status from emp,dept where emp.deptno=dept.deptno and ( employee_status in(Case employee_status when {?Status}=1 then 'A' when {?Status}= 2 then 'T' When {?Status}= 3 then 'A'||','||'T')) OR ( end_date >= {?START_DATE} AND end_date <= {?END_DATE} ) )
Since when i pass employee_status as input 1 it have given me 4 records. When I pass employee_status as input 2 it have given me 3 records. When I pass employee_status as input 3 it should give me 4 records + 3 records=7 records.
4 records for employee_status 'A' 3 RECORDS for employee_status 'T' 7 records for employee_status 'A' AND 'T'
Want to filter a data using CASE statement in WHERE clause for the following scenario.
Need to Filter tb1.fallback_keyword if the fallback_flag is "Y' or 'N' and pg_number is null.Else no partial search of keyword.
where CASE WHEN (fallback_flg = 'Y' OR fallback_flg = 'N') and (pg_number is NULL ) THEN tb1.fallback_keyword = SUBSTR(key_word,1, INSTR(key_word,'#',-2)) ELSE (tb1.keyword = key_word ) AND (tb1.keyword like regexp_replace(key_word, '[*]+', '%')) END
Is it possible within a CASE statement to put conditions on the date range that I want to pull? IE: am versus pm. The query has to pull specific time ranges for an AM run versus a PM run. ..... FROM table WHERE CASE WHEN TO_CHAR(SYSDATE,'AM') = 'AM' THEN table.date BETWEEN TRUNC(SYSDATE) AND SYSDATE ELSE table.date BETWEEN TRUNC(SYSDATE+12/24) AND SYSDATE
BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi PL/SQL Release 10.2.0.1.0 - Production CORE 10.2.0.1.0 Production TNS for Linux: Version 10.2.0.1.0 - Production NLSRTL Version 10.2.0.1.0 - Production
I'm getting this error while executing a package.But this is unpredictable because sometimes it's coming and sometimes it's not. Everytime I'm passing the value as 'ALERT' for the transaction name. Sometimes it's successful and sometimes it's throwing ORA-06592
CASE UPPER(IC_TRANSACTION_NAME) WHEN 'ALERT' THEN SELECT A.FACILITY_ID INTO VN_FACILITY_ID FROM ALERT A WHERE A.ALERT_ID = IN_PARENT_NODE_ID; INSERT INTO TRANSACTION_HISTORY (TXN_HISTORY_ID,
i am doing a data transformation using the following function
FLOOR(ONSET_TPQ-VAX_DATE)
Where ONSET_TPQ and VAX_DATE are both dates. Now in a situation where the ONSET_TPQ precedes VAX_DATE I want the result to be null for those records. As an example if ONSET_TPQ= 2000 and VAX_DATE=2010
I want the result to be NULL as I dont want negative values. Any exact SQl syntax on how to do that. DO i write a case statement?
' FROM (MYDATABASE.STUDENT STUDENT LEFT OUTER JOIN MYDATABASE.BASES CURRENT_SCHOOL '
why the table name student is referenced twice?And again for ' MYDATABASE.BASES CURRENT SCHOOL '?
When I put this into SSRS it shows only links between the tables STUDENT, RELCOATIONS and CURRENT_SCHOOL. Bases isn't mentioned in the tables diagram. it is still referred to in the raw SQL.
The above SQL works fine, i just don't understand what it's doing!
I am facing a problem while retrieving data from table using DECODE/CASE.
Table: PARAM_MSTR
MIN_VALMAX_VALPARAM_CODE DESCRIPTION DATATYPE AB1000 HARD PARAMETERTEXT CN1000 SOFT PARAMETERTEXT 0501001 CRYSTAL PARAMETERNUMBER 512001001 STONE PARAMETERNUMBER
Now I want to get the parameter description based upon the PARAM_CODE and a value passed which should be in range of MIN_VAL and MAX_VAL. Means when I pass PARAM_CODE=1000 and :parameter=A, then it should check the DATATYPE of the PARAM_CODE, in our case it is 'TEXT' so it should check the passed value between MIN_VAL and MAX_VAL like
:parameter BETWEEN MIN_VAL AND MAX_VAL and should return 'HARD PARAMETER'. If I pass PARAM_CODE=1001, then the DATA_TYPE is 'NUMBER', so it will check the :parameter value as Number. Like :parameter BETWEEN to_number(MIN_VAL) AND to_number(MAX_VAL)
For example: PARAM_CODE :parametr Result 1000 A HARD PARAMETER 1000 C SOFT PARAMETER 1000 P NULL 1001 25 CRYSTAL PARAMETER 1001 99 STONE PARAMETER 1001 201 NULL
I have written a query using DECODE and CASE statement but it is not working properly.
SELECT * FROM param_mstr WHERE PARAM_CODE=1000 AND :parameter BETWEEN DECODE(DATATYPE,'NUMBER',CAST(MIN_VAL as NUMBER),MIN_VAL)AND DECODE(DATATYPE,'NUMBER',CAST(MAX_VAL as NUMBER),MAX_VAL)
The query has a case statement in the where clause so that results can be filtered. If I pass "ut" for sso_id then the query returns 21 rows. If I remove the case statement and hard code "a.sso_id like lower('ut'||'%')" then the query returns 41 rows. The query should be returning 41 rows all the time.
Problem:
When passing "ut" as an SSOID parameter to the Procedure the query returns 21 rows.Taking the query and hard coding "a.sso_id like lower('ut'||'%')" the query returns 41 rows.
Result: query should be returning 41 rows when "ut" is passed an an SSOID parameter.
Returns 21 rows
procedure SSO (SSOID in varchar2 default null, Name in varchar2 default null, Campus in varchar2 default null, Department in varchar2 default null,
[code]...
Returns 41 rows
open Results for select a.sso_id, (a.name_last||', '||a.name_first) as name, b.site,
[code]...
Test Data CREATE TABLE ID ( SSO_ID VARCHAR2(60 BYTE), NAME_FIRST VARCHAR2(100 BYTE), NAME_LAST VARCHAR2(100 BYTE),
[code]...
Test Data CREATE TABLE NT ( LOWER_NT_ID VARCHAR2(60 BYTE), DEPARTMENT VARCHAR2(100 BYTE),
We have and Upper and a Lower function.Is there any function or way in which I can issue a select while ignoring the case(like IgNoReCaSe) in a where clause? I don't want to use like
select * from emp where upper(job)= upper('dba'); or select * from emp where lower(job)= lower('dba');
I just want to know if there is any way in which I could do it without using upper and lower.
update siebel.s_contact set marital_stat_cd = case when (marital_stat_cd = 'Casado') then 'Married' when (marital_stat_cd = 'Solteiro') then 'Single' when (marital_stat_cd = 'Divorciado') then 'Divorced' end
As you can see i forgot the else, so my update is wrong.
I thought i could rollback the update issuing the rollback statement, but when i have issue the rollback, the i query the table to confirm that the update was rollbacked and for my suprise the update is commited.
I didn�t issue the commit statement after the update and i confirmed that the auto-commit feature to worksheets is disabled, so i don�t understand whit the update was commited.
In the following merge statement in the USINg clause...I am using a select stament of one schema WEDB.But that same select statement should take data from 30 schemeas and then check the condition below condition
ON(source.DNO = target.DNO AND source.BNO=target.BNO);
I thought that using UNIONALL for select statement of the schemas as below.
Can we use the sequence.nextval,sequence.currval inside case block.
CREATE TABLE EQUALITY_TEST(NUM1 NUMBER, NUM2 NUMBER, SEQ NUMBER); INSERT INTO EQUALITY_TEST VALUES ( 2 ,0 , NULL); INSERT INTO EQUALITY_TEST VALUES ( 2 ,2 , NULL); INSERT INTO EQUALITY_TEST VALUES ( 2 ,2 , NULL); INSERT INTO EQUALITY_TEST VALUES ( 12 ,2 , NULL); INSERT INTO EQUALITY_TEST VALUES ( 12 ,12 , NULL); INSERT INTO EQUALITY_TEST VALUES ( 12 ,12 , NULL); CREATE SEQUENCE SEQ_TEMP START WITH 100 INCREMENT BY 1;
Now i need to update SEQ column with SEQ_TEMP sequence. When NUM1,NUM2 values are unequal sequence should be incremented otherwise need to use the same sequence number(CURRVAL)
I have tried like this
UPDATE EQUALITY_TEST SET SEQ= CASE WHEN NUM1=NUM2 THEN SEQ_TEMP.NEXTVAL ELSE SEQ_TEMP.CURRVAL END ; SELECT * FROM EQUALITY_TEST;
insert into lookups values ('Rent' , 500); insert into lookups values ('Breakpoint' , 10);
create table products (id number, cost number, year varchar2(4));
insert into products values (1, 1000, '2011'); insert into products values (1, 2000, '2011'); insert into products values (2, 100, '2011'); insert into products values (3, 50, '2011');
commit;
I want to write a query which lists the IDs and the sum(cost), and a Y/N indicator which is set to 'Y' IF sum(cost) > ( (lookups.rent value) * (100 - lookups.breakpoint value))/100
I have written this query:
SELECT id, sum(cost)cost, year, CASE WHEN cost > ((SELECT amount [code]....... ORDER BY id;
This returns
ID COST YEAR YN --------- ---------- ---- - 1 1000 2011 Y 1 2000 2011 Y 2 100 2011 N 3 50 2011 N
The YN is correct, but it needs to sum the amounts. So there should only be one row for id1 = 3000.e.g.
ID COST YEAR YN --------- ---------- ---- - 1 3000 2011 Y 2 100 2011 N 3 50 2011 N
I am not sure how to do this. Or is there a better way of doing this than using CASE.
Table X includes multiple transactional records per household.I need to create a mailing list pulling only one record per household, choosing the one with the most recent date.
Each record within this table will have a Household_ID and a Date, so as an example, the table could have
I'm working on a nested case statement, can't seem to get it right.We have a table that has injury_codes. What I'm trying to do is come with a nested case statement that will put the codes in a specific_cat, and based on the specific_Cat, assign a Generic_cat.
Example. I have codes 11,12,13,14,15, 15, 17, 18, 19, 20, 21, 22 Codes 11, 12, 13 have a specific_cat "Head Injury" Codes 14, 15, 16 have a specific_cat "Spinal Injury" Codes 17, 18 have a specific_cat "Burns".
All 3 of these specific_cat come under the generic_cat "Trauma"
Codes 19, 20 have a specific_Cat "High Risk Pregancy" Codes 21, 22 have a specific_cat "Premature Birth".
All 2 of these specific_cat come under the generic cat "OBGYN"...So my case stement should return :
When I tried to have a Cursor with SELECT CASE statement in Forms 6i , it is not working. But the same query is working in SQL PLUS . We cannot use case in Forms 6i ?
select iloan_code,inst_due_date,paid_flag,late_fee,case late_fee when sysdate-inst_due_date between 1 and 10 then 10 when sysdate-inst_due_date > 10 and late_fee <>10 then 5 when sysdate-inst_due_date > 10 and late_fee = 10 then 15 else 0 end as new_late_fee from st_il_schedule where paid_flag='N'; i am getting error
The line highlighted in Bold is where I have the issue. I want it to pick up NULL or Blanks in the method type has well as types E,G,T. I've tried NULL is the statement, "", and '' put none of these work. What am I doing wrong? I'm using 11g by the way
select specialty, member_id, sp_id, service_date, sum(case when method_type = 'C' then (payment_total) end) "CONSULTATION", sum(case when method_type = 'M' then (payment_total) end) "MOT", sum(case when method_type = 'D' then (payment_total) end) "TESTS",
supplier_name = 'IBM' and supplier_type = 'Hardware' THEN
only 'North office' is being retrieved but how to get 'South office' also along with it.Is there a way to write multiple conditions in THEN clause of case stmt something like THEN 'North office' AND 'South office'.
I am very new to Oracle APEX and having difficult with a SQL statement in a report page. I have the following sql code in the page region source.
Essentially, there are two drop down lists connected with the report. I want the first one (:P2_Retailer_ID) to be mandatory, i.e., the user has to select a value from the list, but the second one (:P2_JOBTYPES) to be optional.
So, if the user leaves :P2_JOBTYPES as "No Job Type Chosen" then the SQL returns all records where the retailer ID = P2_RETAILER_ID whereas, if the user also selects a value for P2_JOBTYPES then the SQL returns all records matching both on Retailer ID and Job Type.
However, for some reason, if the user leaves P2_JOBTYPES as "No Job Type Chosen" then no records are returned as it appears to be taking the '%' as a literal value rather than a wildcard.
SELECT * FROM RETPERFFW Where "Retailer_No"= :P2_RETAILER_ID AND (CASE WHEN :P2_JOBTYPES <> 'No Job Type Chosen' THEN :P2_JOBTYPES ELSE '%' END )LIKE "Job_Type_Schema"
The code written in PL SQL.I am using '&' operator to enter the values at run time in nested case statements.But when I chosen a value for case statement even though it is asking all the values which are not part of the selected case statement.I need only the values related to my choice in case statement.
choice1:= &CHOICE_NO1; CASE(choice1) WHEN 1 THEN DBMS_OUTPUT.PUT_LINE('** ENTER YOUR CHOICE TO PERFORM THE OPERATION: **'); DBMS_OUTPUT.PUT_LINE('** (1)INSERTION (2)DELETION (3) UPDATION **'); [code]....
that is my exact code.when I enter value 1 for choice1 and 2 for choice2 It should ask the values only for student_ scorecard. delete_ record (& STUDENTID); &studentid. But it is asking all the functions (student_scorecard.existing_marks(&ID,&SUBJECTNAME));(student_ scorecard. std_ major_ name (&STD_ID)) and procedures.I dont want that.
I am trying to put transactions into 3 different "buckets" for each month of the year.
I am trying to figure out if the syntax for the "else" part of this code is correct... this will basically appear 12 times for each month of the year changing the value for month:
case when floor(sum(total_adjusted_net_amount)/100) < 0 and month in (01) then 0 when floor(sum(total_adjusted_net_amount)/100) > 29 and month in (01) and then 30 else when floor(sum(total_adjusted_net_amount)/100) and month in (01) end Groupin_01
CASE WHEN (EP.ORDER_NUMBER IS NOT NULL AND ATD.IS_DISCONNECT_CREDIT = 1 ) THEN ......... ...... END
In my case when I club two conditions after WHEN in case statement , everytime the first condtion is satisfied (i.e EP.ORDER_NUMBER IS NOT NULL) it is entering into the loop.
Irrespective of using AND or OR after the first condition I am getting the same results.
I want to enter the CASE statement only when both the conditions (1st and 2nd )are satisfied