How this case statement
Hi experts
Please help on this sql statement.
Select case when nvl(:t1,'X') = 'X' then
Select object_name in object where rownum < = 3
on the other
Select double to_char(sysdate,'dd-mm-yyyy')
Double;
When I run the above statement, I get error below
ORA-00936: lack of expression
Hello
You must be a joke...
What is Re: How do I this case summary ? Tell me what you don't like in this solution...
Best regards
Bruno
Tags: Database
Similar Questions
-
How to case statement based on the array of values of 3 or more?
I'm trying to figure out how to do a comparison or case structure... based on the creation of an array of boolean 3 (or maybe more).
I have a table (it's from a serial connection, and I am conversion back to a table to work with) [t, F, F] in this case I would like to display on a status indicator "STBY".
If the array is defined on [F, T, F] I want to display in this indicator "ON".
If the array is defined on [F, F, T] I want to display in this "EMPTY" indicator
I can not understand how to compare combinations of things... I read in an array of bytes, and the first 3 bits in this example, determine what to display in a status... I can't figure out how to do with structure case... or without some channels to research and/or bad comparison...
Any suggestions?
Thanks in advance,
Cayenne
You can use search 1 d array and find the first real.
Or you could convert the table of Boolean integer U8 and integer that results to determine which cases to run. (4, vs, vs 1-2)
-
Why this CASE statement would not work?
If I use a CASE in my SELECT statement and met a strange thing and just need help to understand why he did it.
When I type this, it does not work:
CASE TRIM (Column1)
WHEN NULL THEN Column2
WHEN 'foo' THEN Column2
Of ANOTHER Column1
END AS NewColName
I use this query in an Oracle procedure to insert data into another table. The data inserted in the column of NewColName end up being 4 empty spaces, located in Column1. In the logic of this, TRIM must remove all the empty spaces, and he should get mapped to the first statement WHEN, who must insert the value of Column2, but that does not occur. I tried the following versions of the first line as well:
LTRIM (RTRIM (Column1)) CASE
CASE of REPLACE (Column1, ' ', ")
and they all produce the same result. I also tried to change WHEN NULL for WHEN " and it changed nothing. However, when I rewrite the statement in this way it works the way it should:
CASE
WHEN TRIM (Column1) IS NULL, Column2
WHEN TRIM (Column1) = 'foo' THEN Column2
Of ANOTHER Column1
END AS NewColName
In my mind, it seems that these two methods are trying the same thing, why we could work and the other not? Only, it has no sense to me.
Thank youHello
Welcome to the forum.
In your first statement, you have
WHEN NULL THEN.
This is the same as x = NULL.
Nothing is never equal to NULL, if you find yourself in your ELSE clause.
Concerning
Peter -
Hello
I need help implementation of multiple Case statements in a select statement. I can not it works in a statement.
SELECT statement
1st CASE statement combines the Department_Name and Division_Name values, but does not display the Division_Name if the value is "N/a".select distinct allt.fk_jobcode_id as Job_Code, allt.fk_jobcode_descr as Classification, sum(allt.number_of_positions) as Number_Allotted, sum(number_of_positions) as Sum_Number_Allotted, dept.department_name|| ''||nvl2((CASE WHEN div.division_name <> 'N/A' THEN div.division_name END),'/'||DIV.DIVISION_NAME||'',null) as Department_Division, allt.fund_type as Fund from tbl_allotment allt, tbl_department dept, tbl_division div where isdeleted <> 'Y' and ALLT.FK_DEPARTMENT_ID = dept.department_id and ALLT.FK_DIVISION_ID = div.division_id group by fk_jobcode_id, fk_jobcode_descr, fund_type, department_name, division_name HAVING (count(fk_jobcode_descr ) = 1) order by Classification asc, Department_Division asc
value: administrator Office/Administration Councildept.department_name|| ''||nvl2((CASE WHEN div.division_name <> 'N/A' THEN div.division_name END),'/'||DIV.DIVISION_NAME||'',null) as Department_Division,
value: poster of the administrator of the Office/s/o Board in the Office of the Director of the Board
I need to extend this now using this CASE statement, which displays the text "Public works" If the department_id = 00072.
incorrect: road Rehab program/GLP transport program Admin(CASE dept.department_id When '00072' then 'Public Works' Else dept.Department_Name End) as Department_Name,
Must fill as: work GLP/public transport program Admin
but once I change the select statement I get only value "Public works" for the Department_Division value. Does not meet Division_Name data. Does anyone know how to combine these CASE statements? Thanks for reading this thread also.select distinct allt.fk_jobcode_id as Job_Code, allt.fk_jobcode_descr as Classification, sum(allt.number_of_positions) as Number_Allotted, sum(number_of_positions) as Sum_Number_Allotted, dept.department_name|| ''||nvl2((CASE WHEN div.division_name <> 'N/A' THEN div.division_name END),'/'||DIV.DIVISION_NAME||'',null) as Department_Division, (CASE dept.department_id When '00072' then 'Public Works' ELSE dept.Department_Name|| ''||nvl2((CASE WHEN div.division_name <> 'N/A' THEN div.division_name END),'/'||DIV.DIVISION_NAME||'',null) END) as Department_Name1, allt.fund_type as Fund from tbl_allotment allt, tbl_department dept, tbl_division div where isdeleted <> 'Y' and ALLT.FK_DEPARTMENT_ID = dept.department_id and ALLT.FK_DIVISION_ID = div.division_id group by fk_jobcode_id, fk_jobcode_descr, fund_type, department_name, division_name, department_id HAVING (count(fk_jobcode_descr ) = 1) order by Classification asc, Department_Division asc
Hello
I think you want something like this:
SELECT ... , CASE WHEN department_id = '00072' THEN 'Public Works' ELSE dept.department_name END || CASE WHEN div.division_name != 'N/A' THEN '/' || div.division_name END AS department_name1 ...
Whenever you have a problem, post a small example (CREATE TABLE and only relevant columns, INSERT statements) of all database tables.
Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
Always tell what version of Oracle you are using. -
Hi experts, PL/SQL,.
I'm going a little crazy here, so could someone please point out what I am doing wrong with this case statement:
Test procedure is:
CREATE or REPLACE procedure SCOTT.postcode_validate_2 (input_post_code VARCHAR2) as
alphabet_string VARCHAR2 (52): = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvxwyz";
number_string VARCHAR2 (10): = '012345789';
last_part_postcode VARCHAR2 (3): = NULL;
BEGIN
IF INSTR (input_post_code,' ') = 0
THEN
DBMS_OUTPUT. Put_line ("' it takes a space in the zip code please");
GOTO end;
ELSIF LENGTH (SUBSTR (input_post_code, instr (input_post_code,' ') + 1)) > 3
THEN
DBMS_OUTPUT. Put_line ("the last part of the postcode can be 3 characters");
GOTO end;
ON THE OTHER
last_part_postcode: = SUBSTR (input_post_code, instr (input_post_code,' ') + 1);
END IF;
CASE input_post_code
WHEN (length (substr (input_post_code, 1, instr(input_post_code,' ')-1)) = 2)
AND instr (alphabet_string, substr(input_post_code,1,1)). = 0
AND instr (number_string, substr(input_post_code,2,1)). = 0)
THEN
DBMS_OUTPUT. Put_line ('we have a valid postal code in the format A9')
-OTHER
-DBMS_OUTPUT. Put_line ("sorry, but this is an incorrect postal code!") Format A9');
-GOTO end;
-END IF;
WHEN (length (substr (input_post_code, 1, instr(input_post_code,' ')-1)) = 3)
AND instr (alphabet_string, substr(input_post_code,1,1)). = 0
AND instr (alphabet_string, substr(input_post_code,2,1)). = 0
AND instr (number_string, substr(input_post_code,3,1)). = 0)
THEN
DBMS_OUTPUT. Put_line ('we have a valid postal code in the format AA9')
-OTHER
-DBMS_OUTPUT. Put_line ("sorry, but this is an incorrect postal code!") AA9 format');
-GOTO end;
-END IF;
WHEN (length (substr (input_post_code, 1, instr(input_post_code,' ')-1)) = 3)
AND instr (alphabet_string, substr(input_post_code,1,1)). = 0
AND instr (number_string, substr(input_post_code,2,1)). = 0
AND instr (number_string, substr(input_post_code,3,1)). = 0)
THEN
DBMS_OUTPUT. Put_line ('we have a valid postal code in the A99 format')
-OTHER
-DBMS_OUTPUT. Put_line ("sorry, but this is an incorrect postal code!") A99 format');
-GOTO end;
-END IF;
WHEN (length (substr (input_post_code, 1, instr(input_post_code,' ')-1)) = 3)
AND instr (alphabet_string, substr(input_post_code,1,1)). = 0
AND instr (number_string, substr(input_post_code,2,1)). = 0
AND instr (alphabet_string, substr(input_post_code,3,1)). = 0)
THEN
DBMS_OUTPUT. Put_line ('we have a valid postal code in the format A9A')
-OTHER
-DBMS_OUTPUT. Put_line ("sorry, but this is an incorrect postal code!") A9A format');
-GOTO end;
-END IF;
WHEN (length (substr (input_post_code, 1, instr(input_post_code,' ')-1)) = 4)
AND instr (alphabet_string, substr(input_post_code,1,1)). = 0
AND instr (alphabet_string, substr(input_post_code,2,1)). = 0
AND instr (number_string, substr(input_post_code,3,1)). = 0
AND instr (number_string, substr(input_post_code,4,1)). = 0)
THEN
DBMS_OUTPUT. Put_line ('we have a valid postal code in the format AA99')
-OTHER
-DBMS_OUTPUT. Put_line ("sorry, but this is an incorrect postal code!") AA99 format');
-GOTO end;
-END IF;
WHEN (length (substr (input_post_code, 1, instr(input_post_code,' ')-1)) = 4)
AND instr (alphabet_string, substr(input_post_code,1,1)). = 0
AND instr (alphabet_string, substr(input_post_code,2,1)). = 0
AND instr (number_string, substr(input_post_code,3,1)). = 0
AND instr (alphabet_string, substr(input_post_code,4,1)). = 0)
THEN
DBMS_OUTPUT. Put_line ('we have a valid postal code in the format AA9A')
-OTHER
-DBMS_OUTPUT. Put_line ("sorry, but this is an incorrect postal code!") AA9A format');
-GOTO end;
-END IF;
END;
-Check the last part of the format, should be AA9
IF (instr (number_string, substr(input_post_code,1,1))! = 0)
AND instr (alphabet_string, substr(input_post_code,2,1)). = 0
AND instr (alphabet_string, substr(input_post_code,3,1)). = 0)
THEN
DBMS_OUTPUT. Put_line ('end part of the code postal is the appropriate format, 9AA');
ON THE OTHER
DBMS_OUTPUT. Put_line ("' end part of the postcode is in a wrong format!");
END IF;
< < output > >
DBMS_OUTPUT. Put_line ("Please try again");
END;
/
However, I get the following error:
LINE/COL ERROR
-------- -----------------------------------------------------------------
37/6 PLS-00103: encountered the symbol "WHEN" what awaits an of
What follows:
:= . ( % ;
On a second note, can't be incorporated into the (currently commented) case ELSE structure?
Thank you very much in advance.
DevThe initial error was just a problem with your procedure. The other has to do with how you use the CASE statement.
The code seems a bit long for what you're trying to do. Could you describe what your needs are? -
CASE STATEMENT DOES NOT HIERARCHY
Hi Experts
I have this case statement:
BOX WHEN ' @{pvCalType} "="Cal1"THEN"Calendar Cal1"". "" Year. "
WHEN ' @{pvCalType} "="Cal2"THEN"Calendar Cal2"". "" Year
ANOTHER NULL
END
All the columns in the YEAR of different sizes have properties of the hierarchy.
When I view my results of this statement, there is no hierarchy.
I want the hierarchy in order to drill down of the YEAR > QUARTER > MONTHS
Help, please.
Hello
do you have other possible values for "pvCalType"?
If not try this formula: "@{pvCalType} schedule". " Year. "
(not sure this is the right syntax, if it does not work after the return of the error and I get the right thing...)
-
Case statement in the SQL Query prompt dashboard
Hi Experts,
I use the following case statement to generate default values in the prompt dashboard based on a condition (the other guest-generated values). Below are two of the query I've tried and the syntax error. I tried all the possibilities (like giving apostrophes, double quotes, don't quote not etc.), but could not understand the question. Don't know what exactly I'm missing here.
Query 1:
SELECT
CASE
WHEN @{PRType} = monthly THEN 'Participant pay '. "" Amount of PayRate "="15000"
WHEN @{PRType} = daily THEN 'Participant pay '. "" Amount of PayRate "="650"
WHEN @{PRType} = hourly THEN 'Participant pay '. "" Amount of PayRate "="1"
ELSE ' 0'
END
OF 'PA-Participant pay. '
Query 2:
SELECT
CASE
WHEN @{PRType} = monthly THEN "15000"
WHEN @{PRType} = daily THEN "650"
@{PRType} = schedule THEN '1'
ELSE ' 0'
END
OF 'PA-Participant pay. '
This is the query that is generated in the log with error message file.
1 log message:
SELECT CASE WHEN Hourly = Monthly THEN "Participant Payroll"."Payrate Amount" = '15000' WHEN Hourly = Daily THEN "Participant Payroll"."Payrate Amount" = '650' WHEN Hourly = Hourly THEN "Participant Payroll"."Payrate Amount" = '1' ELSE '0' END FROM "PA-Participant Payroll"
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 43113] The message returned by OBIS. [nQSError: 27002] Near <>=: Syntax error [nQSError: 26012]. (HY000)
Comment 2:
;CASE WHEN To_Char (Hourly) = 'Hourly' THEN 1 ELSE 0 END
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 43113] The message returned by OBIS. [nQSError: 27002] Near <>(): syntax error [nQSError: 26012]. (HY000)
Sorry, I wasn't clear... you must always put this CASE statement in a valid SQL SELECT statement.
SELECT
CASE
When ' @{PRType}' = 'Monthly' THEN '15000'
When ' @{PRType}' = 'Daily' THEN '650'
ELSE '0' END
OF 'PA-Participant pay. '
-
Hi all!
A work colleague published some analysis I built and messed up some column formulas, I did. I am trying to summarize this case statement:
CASES WHERE "claim Cmplt - various. "" Number special String ' AS ' % ~ 109 ~ %' THEN 'D1BC' WHEN ' claim Cmplt - various. "" Number special String ' IS NULL OR "claim Cmplt - various. "" String of the special issue "LOVE NOT ' % ~ 100 ~ %" OR "claim Cmplt - various" "." " Chain of the special issue"do NOT LIKE ' % ~ 99 ~ %" OR "claim Cmplt - various" "." " Chain of the special issue"do NOT LIKE ' % ~ 49 ~ %' THEN 'VSC' END
The formula works like this. When I go to SUM it, I'm missing something... you can identify what it is?
SUM (CASE WHERE "claim Cmplt - various".) "" Number special String ' AS ' % ~ 109 ~ %' THEN 'D1BC' WHEN ' claim Cmplt - various "". "" "Number special String ' IS NULL OR" claim Cmplt - various. "" String of the special issue "LOVE NOT ' % ~ 100 ~ %" OR "claim Cmplt - various" "." " Chain of the special issue"do NOT LIKE ' % ~ 99 ~ %" OR "claim Cmplt - various" "." " (Chain of the special issue"do NOT LIKE ' % ~ 49 ~ %' THEN 'VSC' END)
Thanks gurus!
Don't know what you expect here by using sum. Money is not the columns of type char, but you can go for the County that would work.
hope you guessed it.
Mark as correct
-
Help in the CASE statement with amount
Hello Experts
I amw Group on
Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
With partitioning, OLAP, Data Mining and Real Application Testing options
I'm unable to solve this Case statement.
My requirement is that if the value of the attribute is greater than 50, then add 1 to the sum for attribute 4 the sum should be 4
WITH T AS
(
Select MATH_CONV_SCR 70, 68 MATH_PERC, writ_conv_scr 66, 67 writ_per Union double all the
Select MATH_CONV_SCR 70, MATH_PERC 48, writ_conv_scr 66, 67 writ_per Union double all the
Select MATH_CONV_SCR 70, 68 MATH_PERC, writ_conv_scr 66, 67 double writ_per
)
(
Select)
CASE
WHEN MATH_CONV_SCR > 50 THEN 1
WHEN MATH_PERC > 50 THEN 1
WHEN WRIT_CONV_SCR > 50 THEN 1
WHEN WRIT_PER > 50 THEN 1
TOTAL END)
T
)
The expected answer is
4
3
4
for the respective folders
Please give me the solution
Thank you
RBHello
Rb2000rb65 wrote:
Hello ExpertsI amw Group on
Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production...
Thanks for posting the version and sample data; It is very useful.
... Select)
CASE
WHEN MATH_CONV_SCR > 50 THEN 1
WHEN MATH_PERC > 50 THEN 1
WHEN WRIT_CONV_SCR > 50 THEN 1
WHEN WRIT_PER > 50 THEN 1
TOTAL END)
TDon't forget that the WHEN of a CASE expression clauses are mutually exclusive. If none of them are evaluated to TRUE, then all of the following are not even tried.
)
The expected answer is
4
3
4
for the respective foldersPlease give me the solution
Here's one way:
SELECT CASE WHEN math_conv_scr > 50 THEN 1 ELSE 0 END + CASE WHEN math_perc > 50 THEN 1 ELSE 0 END + CASE WHEN writ_conv_scr > 50 THEN 1 ELSE 0 END + CASE WHEN writ_per > 50 THEN 1 ELSE 0 END AS total FROM t;
-
How can I write a case statement if I want a case for x< 1.5; ="" a="" case="" for="" 1.5=""><= x="">=><= 3.7; ="" case="" for ="" 3.7="">=>< x="">< 7.2.....etc. ="" my="" input="" is="" a="" floating="">
Thank you.
You don't seem to have set rules on inclusion, but I often use the function in the range and Coerce in these cases.
-
How to track down where a specific enum is used in a switch case statement?
Hi all
I have an application of simulation of machine quite complex state that I add a 'mode' feature for. Some States in the application, rather than the blocks by default of running code, a VI a VI class for each mode will be instead (for example for modes A and B, initialization status has now Initialization_modeA and Inilitalization_modeB). This results in many cases structures everywhere, and I can't figure out how to ensure that, when adding a new mode, I have add the case of this mode of each switch case. Is it as simple as having a default case with a pop-up box? Or is it possible OOP I can handle this?
Go right on what you told us, you could have each mode inherited from a common ancestor that defines a set of common States (or methods in this case). Whenever you want to add a new method, you can create a new class and override simply each method with this specific class has to do. Instead of having a State of init for each mode, you only then a common State of init, which would then distribute the code correct init based on what class you are using.
-
How to fill a table only if a case statement runs?
Hello. I want to have a while loop with a case statement. When the case is true, it should read the analog data each iteration of the while loop via Daqmx and store these values in a table. If the case is wrong, I don't want to read all the data or to store anything else in the table. When the loop is finished, I want to have this available table to write to a file or something. How can I go about it?
Search for a "shift register. This will hold your data. In the case of fake feed the data in the table back through without change. In the case of true add the new value in the table to "build the table" or even better "subset of the table to replace' for a defined table size.
-
How can you change a menu drop-down menu in a case statement?
Hello
I'm trying a table find vi. This VI will be an existing xml file and once the user has selected access to its equipment, input, output and frequency it put all of these options in a string and search the XML for this exact table name and post it on one screen of output. The problem I have is my entry and exit selection must be a little different depending on the chosen equipment. I thought I could use an instruction box to change the options of selectable input and output, but I ran into snags a lot with it. For whenever I have to put a new drop of entry and exit in the drop-down menu in the case statement, he wants to put a new one in the front (I only want to enter and exit not only three I have two inputs and outputs hidden right now). I think I'm using the wrong case statement... Can someone help change my input and output, selectable options depending on the chosen equipment. Attached is my xml file, Array Find.vi (the original) and table Find_Test.vi (that's what I'm trying to change).
Thank you
dlovell
Hi dlovell,
A few changes in the attached VI:
Requirements/possible Solutions
- When the value of the equipment, do something
- Add the cases to the value of equipment change event
- Do something = decide what channels to write, to change the input and output strings
- Read material value changed
- Decision (case structure)
- Channel (same method as the previous mod)
Hope this helps
-
I have problem with value NULL when the use CASE statement please help this question
I have problem with value NULL when the use CASE statement please help this question
Table: digital_val
SNO cl C2
1 San1 11
2 22 San2
Actual result: expected to A B
A B 11 22
11 NULL
22 NULL
query:
Select case when c1 = "san1" then c2,.
case If c1 = "san2" then c2 B
of digital_val
I'm more curious why, when you select 2 rows, you expect a result of row?
WITH digital_val
AS (SELECT 1 AS 'Sno', 'San1"C1, c2 FROM DUAL 11)
UNION ALL
2 SELECT AS 'Sno', 'San2"C1, c2 FROM DUAL 22)
SELECT CASE WHEN c1 is "San1" THEN END AS A c2.
CASE WHEN c1 = "San2" THEN END AS B c2
OF digital_val;
With no other input, if you select 2 rows, you get 2 rows. One of the other solutions use a max function, but is this really what you want, does not specify?
-
have no interest in talking to the Adobe community. I want Adobe to take the money I gave them everything and give me a version of Acrobat Reader that works on a Mac. How can I get a real representative of Adobe to handle this case? This breath.
Just to clarify: there is no product called 'Acrobat Reader Standard' or 'Acrobat Reader Pro "; three cloud paper products
- Acrobat Reader (free) DC
- Acrobat Standard DC
- Acrobat Pro DC
Maybe you are looking for
-
When I logout of e-mail is g-mail or yahoo, Firefox email in a new window and not the window being closed. The current window looks like that I have not disconnected.
-
Re: Satellite A660 - 11 M - Random freezing after the installation of recovery
Hello I recently bought an A660 - 11 m, which I was happy for a few months and then it started to crash/freeze randomly in windows. I'd do something and then it just would freeze indefinitely, requiring a second 5 press the power button to turn it of
-
Reset password BIOS HP Pavilion G6-1d89WM
HP Pavilion G6-1d89WM Error code is 63231019
-
Can I remotely from a computer that does not have control with LabVIEW?
Hi, I have a PC at work that has LabVIEW (LV) installed, and I order several machines using a GPIB/USB interface. I would like to be able to control them remotely, at home, so I can start new experiences without having to enter in my lab. However, my
-
Chromebook C720 - no mobile internet connection with my usb dongle - even not recognized.
Hello Your help please. I use an Acer C720 Chromebook bought in England but I am now at the Brazil and I can't access my mobile data plan - the operator is TIM and the dongle is Olivetti, Olicard 160. I can access the WiFi from the nearby square, but