Problem in the counting by SQL case statement
I have a table with 3 columns-create table execution_stg)
number of alc_td_id
number of exe_td_id
src_sys varchar2 (50)
)
I want to get the number of records with alc_td_id not null and not null exe_td_id and total count by src_sys.
When to use a query like this-
SELECT src_sys,
CASE
WHEN alc_td_id IS NOT NULL
THEN THE SUM (1)
END as alc_ac_cnt,
CASE
WHEN exe_td_id IS NOT NULL
THEN THE SUM (1)
END AS td_ac_cnt, COUNT (*) AS total_cnt
Of execution_stg
GROUP BY src_sys
I get ORA-00979 - isn't a group by expression.
What should I do?
Thank you
-Christian Plantier S
Edited by: girija_pathak may 3, 2010 12:55
Edited by: girija_pathak may 3, 2010 13:05
Never mind...
Edited by: AlanWms may 3, 2010 16:09
Tags: Database
Similar Questions
-
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? -
Join the results of a case statement
Hello everyone;
I can't with a query where I use a case statement to create a new column and attempt to reach an additional table on the resulting column. I am fairly new to this and learn by trial and error, so if you think that it looks a little ugly or ineffective, I won't be offended. It is used on my interface based on the web of companies, while I am not able to answer some basic questions such as the version of db.
My need to use the case statement is the result of some strange methods and somewhat contradictory in order to link the product subcodes (sku, fcsku, fnsku), to a product code parent (ProdID). In this case, the inventory is stored in the first table with one of the few types of premises SKUs, however the dimensional data only links to the ProdID. I'm trying to instruction box allows to send the parent a second table (ProdID) code if the sku is there, or a third table if it is found on this table. The main reason (in this case) I have to this ProdID is I can join the dimensional data of a fourth table.
My current query:
SELECT / * + USE_HASH (dbin, sku, xProdID, msr) * /.
dbin.snapshot_date, dbin.bin_id, dbin. ISBN,
CASE WHEN sku. ProdID IS NULL THEN xProdID.ITEM_AUTHORITY_ID
Of ANOTHER sku. ProdID
END ProdIDMaster,
dbin. OWNER, dbin. QUANTITY, dbin. CONTAINER_ID,
MSR. HEIGHT, msr. WIDTH, msr. LENGTH, msr. WEIGHT, msr. DIMENSIONAL_UOM, msr. WEIGHT_UOM,
MSR. HEIGHT * msr. WIDTH * msr. LENGTH as a Volume
OF D_BIN_ITEMS dbin
SKU of LEFT JOIN O_FCSKUS ON dbin. ISBN = sku. FCSKU
LEFT JOIN (SELECT * FROM D_FNSKU_ProdID_MAP)
WHERE REGION_ID = 1
AND SNAPSHOT_DAY = TO_DATE('{RUN_DATE_YYYY/MM/DD}','YYYY/MM/DD')) xProdID
ON dbin. ISBN = xProdID.FULFILLMENT_NETWORK_SKU
LEFT JOIN (SELECT * FROM D_MP_ProdID_PKG_MEASUREMENTS)
WHERE REGION_ID = 1 AND MARKETPLACE_ID = 1 AND PACKAGE_TYPE_ID = 1) msr
ON ProdIDMaster = msr. ProdID
WHERE dbin. WAREHOUSE_ID = "PHL5."
AND dbin. Snapshot_date = TO_DATE('{RUN_DATE_YYYY/MM/DD}','YYYY/MM/DD')
AND dbin.bin_id like '% P-1-R '.
ORDER BY dbin.bin_id;
The error I receive:
Statement 1 is invalid. ORA-00904: "ProdIDMaster": invalid identifier
ProdIDMaster appears only in two places, an alias for the case statement, as well as a side of the join statement. If I simply change the alias name, it has no effect, so I can only assume the question is how I refer to results of the case statement. I also tried to reach the word 'CASE', which returned "1 statement is not valid. "ORA-00904:"The MATTER": invalid identifier.
Any help or advice would be greatly appreciated.
Post edited by: 8ea4344e-80ea-44e7-b8ac-d482be7245a7 I made a mistake when I posted the code. The ProdID_ID shown in the join should have been ProdIDMaster. I need to change this due to the fact that the name of the column used (which is what I based my alias on) may have been considered confidential information. All the other columns names remained unchanged.
Hello
8ea4344e-80EA-44e7-B8AC-d482be7245a7 wrote:
Hello everyone;
I can't with a query where I use a case statement to create a new column and attempt to reach an additional table on the resulting column. I am fairly new to this and learn by trial and error, so if you think that it looks a little ugly or ineffective, I won't be offended. It is used on my interface based on the web of companies, while I am not able to answer some basic questions such as the version of db.
My need to use the case statement is the result of some strange methods and somewhat contradictory in order to link the product subcodes (sku, fcsku, fnsku), to a product code parent (ProdID). In this case, the inventory is stored in the first table with one of the few types of premises SKUs, however the dimensional data only links to the ProdID. I'm trying to instruction box allows to send the parent a second table (ProdID) code if the sku is there, or a third table if it is found on this table. The main reason (in this case) I have to this ProdID is I can join the dimensional data of a fourth table.
My current query:
SELECT / * + USE_HASH (dbin, sku, xProdID, msr) * /.
dbin.snapshot_date, dbin.bin_id, dbin. ISBN,
CASE WHEN sku. ProdID IS NULL THEN xProdID.ITEM_AUTHORITY_ID
Of ANOTHER sku. ProdID
END ProdIDMaster,
dbin. OWNER, dbin. QUANTITY, dbin. CONTAINER_ID,
MSR. HEIGHT, msr. WIDTH, msr. LENGTH, msr. WEIGHT, msr. DIMENSIONAL_UOM, msr. WEIGHT_UOM,
MSR. HEIGHT * msr. WIDTH * msr. LENGTH as a Volume
OF D_BIN_ITEMS dbin
SKU of LEFT JOIN O_FCSKUS ON dbin. ISBN = sku. FCSKU
LEFT JOIN (SELECT * FROM D_FNSKU_ProdID_MAP)
WHERE REGION_ID = 1
AND SNAPSHOT_DAY = TO_DATE('{RUN_DATE_YYYY/MM/DD}','YYYY/MM/DD')) xProdID
ON dbin. ISBN = xProdID.FULFILLMENT_NETWORK_SKU
LEFT JOIN (SELECT * FROM D_MP_ProdID_PKG_MEASUREMENTS)
WHERE REGION_ID = 1 AND MARKETPLACE_ID = 1 AND PACKAGE_TYPE_ID = 1) msr
ON ProdIDid_ID = msr. ProdID
WHERE dbin. WAREHOUSE_ID = "PHL5."
AND dbin. Snapshot_date = TO_DATE('{RUN_DATE_YYYY/MM/DD}','YYYY/MM/DD')
AND dbin.bin_id like '% P-1-R '.
ORDER BY dbin.bin_id;
The error I receive:
Statement 1 is invalid. ORA-00904: "ProdIDMaster": invalid identifier
ProdIDMaster appears only in two places, an alias for the case statement, as well as a side of the join statement. If I simply change the alias name, it has no effect, so I can only assume the question is how I refer to results of the case statement. I also tried to reach the word 'CASE', which returned "1 statement is not valid. "ORA-00904:"The MATTER": invalid identifier.
Any help or advice would be greatly appreciated.
Whenever you have a problem, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables involved, so that people who want to help you can recreate the problem and test their ideas.
Also post the exact results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
Always say what version of Oracle you are using (for example, 11.2.0.2.0). Use "SELECT * VERSION of $ v;" to get it.
See the FAQ forum: Re: 2. How can I ask a question on the forums?
When you define an alias for column (such as PriodIDMaster) in the SELECT a query clause, you can use the alias in the ORDER byclause in this request, but this is the only place in this same query, where you can use it. If you want to use anywhere, like in a join condition, then calculate the new column in a subquery; then you can use it anywhere you want in a Super request.
I see expression BOX (not the same as a declarationBOX) where when ProdIDMaster is defined, but I do not see where it is used. Are you sure that you posted the code that is causing the problem?
-
Problem with the process running sql
I created a pricess that deletes a file off of the table apex_application_files
When I run the following statement:
delete apex_application_files whose name like "resume.pdf" it works without problem
When I run the following statement:
delete apex_application_files whose name like ': P4_PDF_DISPLAY' he does not. what I have to do.
I changed the: p4_pdf_display to be a single item displayed on the page
With the help of the P4_PDF_DISPLAY can view the file in a query sql and beable to view the file to download, but am unable to delete
Help!Hello
>
I created a pricess that deletes a file off of the table apex_application_filesWhen I run the following statement:
delete apex_application_files whose name like "resume.pdf" it works without problemWhen I run the following statement:
delete apex_application_files whose name like ': P4_PDF_DISPLAY' he does not. what I have to do.I changed the: p4_pdf_display to be a single item displayed on the page
With the help of the P4_PDF_DISPLAY can view the file in a query sql and beable to view the file to download, but am unable to delete
>What is this point of P4_PDF_DISPLAY? It is the name of the file, as it is supposed to be in your delete statement? Or, view the article PDF?
Verify session state to display the value of the element. You see the name in it?See you soon,.
-
A PROBLEM IN the INSTALLATION of SQL SERVER
I HAVE PROBLEM IN INSTALLING SQL SERVER, I HAVE 8 64-BIT LENOVO WINDOWS, I TRIED SEVERAL VERSIONS, BUT IT DOES NOT YET :(
PLEASE HELP ME!
Hi John,
Since it is a linked server query, I suggest you to send this request in the Microsoft TechNet forum where you might find similar messages and also get answers to your query. Here is a link to the forum:
-
I have a table as follows. The return of the role-based query. If the role is 'a', the result should be abc, edf, and xxx. If the role is b results should be abc, yyy. When the role is * (all) then means that the results should be possible all the code.
role of Code
an abc
an edf
a xxx
abc b
b yyy
c *
I'm trying to build something like this, but it gives me the error. Could someone help me?
Select the case ID when ' *' then (select Code separate from table_name)
end
table_name from where role =: input_role
Thank you very much!Hello
I think I uderstand. Try this:
SELECT xxx, yyy, zzz FROM another_table a WHERE a.code IN ( SELECT CASE WHEN b.code = '*' THEN a.code ELSE b.code END FROM this_table b WHERE b.role = :input_from_user ) ;
NULL in (...) is never true, so I assume that you do not want to include all rows where another_table.code is NULL, even if the subquery is a ' *'.
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data. Give some examples of: input_from_user and the resutls, you want the same data for each of them.
Explain, using specific examples, how you get these results from these data.
Another_table.code can be null? Is there any value (such as ' ~? ~') that you can never occurs in another_table.code? The combination (xxx, yyy, zzz) is unique in another_table?
Always tell what version of Oracle you are using. -
How to use the Substring function with Case statement.
Hi all
I have a requirement where I have to use the substring function on the ground for the report criteria.
FOR EXAMPLE
I branch domain name where I have all the information of the branch names, now some of the branch names are too large with an extension after the name.
now I want substing it, but the length of characters varies for each branch.
so is it possible where we use a box where we can define if the character of name plug exceed a value then he substing with this length.Try something like this:
LENGTH WHEN CARTER (tablename. Branch_Name) > n THEN SUBSTRING (...) Of ANOTHER tablename. Branch_Name END
where n is the number of characters that you want to start the break.
-
problem in the counting of panelTabbed
I develop my special skin and when I extends on the skin (fusion.desktop), do not apply this selectors:
AF | panelTabbed:tab - text-link {color: Darkgreen ;}}
AF | panelTabbed:tab - text-link: hover {text-decoration: none; color: Orange ;}}
AF | panelTabbed:tab - text-link: selected {color: Purple ;}}
AF | panelTabbed:tab - text-link: selected: hover {make-style: italic ;}}
AF | panelTabbed:icon - style {border: 1px solid ;}}
with others means such as simple, rich in blafplus it works fine...
Can someone help...Try to use it like this:
AF | panelTabbed::tab af | panelTabbed:tab - text-link {color: Darkgreen ;}}
...
If this does not work then try adding! important:
AF | panelTabbed::tab af | panelTabbed:tab - text-link {color: Darkgreen! important ;} / * only if there is no other way!} */ -
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.
-
Hi all
I have a calculation in a report of Discoverer Desktop with 29 instructions BOX and still 2 case statements more to add. The problem is that my report freezes and fails to run due to the excessive number of case statements. I need to put the 31 statemnts cases in the report, how do I do this? Is there another way to do it without causing the report to freeze?
Below is part of my instructions box just to show you what I'm doing:
CASE WHEN Ex = 'MM' AND THEN of OTHER NULL result (', ')
CASES WHERE Ex = "PP" AND result IN (40,35,30,25) THEN NULL OTHERWISE
CASE WHEN Ex = he's ' AND result IN (' a ',' B', 'C', d ') THEN NULL OTHERWISE
-CASE WHEN Ex = 'IO' AND THEN of OTHER NULL result ('Distinction', 'Merit')
-CASE WHEN Ex IN ('ZZ', 'WW', 'SS', 'KK') AND ('PASS', 'P') THEN to ANOTHER NULL result...
The last statement should be BOX WHEN... THEN NULL OTHERWISE 1 END END END END...
Help, please. Thank you.Hello
You have reached the limit of characters in a calculation.Try to set into a single statement as follows:
CASE WHEN Ex = 'MM' AND THEN of OTHER NULL result (', ')
WHEN Ex = "PP" AND as a result (40,35,30,25) THEN NULL OTHERWISE
WHEN Ex = he's ' AND result IN (' a ',' B', 'C', d ') THEN NULL OTHERWISE
WHEN Ex = 'IO' AND THEN of OTHER NULL result ('Distinction', 'Merit')
WHEN Ex IN ('ZZ', 'WW', 'SS', 'KK') AND ('PASS', 'P') THEN to ANOTHER NULL result...The last statement should be BOX WHEN... THEN NULL OTHERWISE 1 END
Another option is to combine all the statements of NULL in a series of gold options like this:
BOX WHEN
(Ex = 'MM' AND the result in (', am')) OR
(Ex = "PP" AND result IN (40,35,30,25)) OR
(Ex = he's ' AND translated BY (' a ',' B', 'C', ')) OR
(Ex = 'IO' AND as a result ('Distinction', "according to merit")) OR
(Ex IN ("ZZ", "WW", "SS", "KK") AND result IN ('PASS', 'P')) THEN ANOTHER NULL...Best wishes
Michael -
Case statement "when IN the cursor.
Hi people.
I wonder if it is possible to use the IN within a CASE statement?
I'm trying to see if a parameter is certain dates in another table. I have a cursor declared which points to this date column, and looks like my case statement so
case parameter_date IN certain_dates then if_holiday: = 1 else if_holiday: = 2 end;
It doesn't when I try to compile. And my procedure is listed as invalid.
Thanks for any help :)I have the Case statement without the right to choose?
Only if specify you on literals as follows
in ('WHATEVER', 'DUDE', 'RUG')
You cannot use a variable.
I guess it may be easier if I just use an if statement.
Ah, is this a CASE of PL/SQL rather than a SQL CASE? Not that it makes a lot of difference. In any case, if this world is IF... ELSIF easier than the CASE? I mean, I'm a traditionalist, and I prefer even the syntax of the CASE.
Cheers, APC
blog: http://radiofreetooting.blogspot.com
-
Increment of the counter without using the shift register
Is there a way to count = count + 1, with using a node registry or feedback shift? I have a structure of the event within a while loop (see table). When the button is touched (kickoff event), a test is carried out. Based on the test in the case of a string is passed outside of the event to a case statement of success/failure. The user can run one of these 'events' as many times as he or she wishes. And in an order any... Test1 (fails)... test 1 (fails)... again... test1 (go) again... test 2 (pass) then test 1 (pass). When the stop button is reached, I would like to know how many times each pass/fail is produced for each test. Try to stay away from shift registers, as I have 18 w key so a possible failure for each, so I would need 36 shift registers.
In my example, the printed final statement would be:
TEST PASS/fail # x test was performed
test1 failure 1
2 in case of failure test1
Test1 pass 3
Test2 pass 1
4 passes test1
etc.
Do not see an attachment.
You can use a shift register to store a table.
Each button would be mapped to an array index. For each button pushed you the value of the index table, + 1, replace the array element and pass out back for the shift register.
-
Problem SQL querry (case statement...)
Hi to everyone who reads this.
I have a huge problem (at least for me) with a SQL I try to write in Oracle forms6 (yes I know... old app).
OK, here it goes...
We have a table like:
The data in the table are:create table temp ( year number month number, konto number, DEBET number, KREDIT number, date_tr date, ind number );
Now, to explain a little what I want to do...YEAR MONTH KONTO DEBET KREDIT DATE_TR IND ---------- ---------- ----- ---------- ---------- -------- - 2011 1 12101 4674,32 0 05.06.11 2011 6 12101 -4674,32 0 05.06.11 R 2011 6 12182 4674,32 0 R
What I need is when p_date is entered by a user SQL should check if the date is less or greater than date_tr...case when p_date > NVL(date_tr,'01012004') then date_tr is null; else ind is null end
in this case it should show only the record that has a null value in date_tr cullum.
Or if it isn't... it should display records which is null in ind cullum.
The main problem is that I do not know how to write the case statement in SQLs where clause... maybe someone can give me a hint
or a partial code how do I solve this problem.
Any ideas would be greatly apreciated.
Thanks to you all!SQL> with temp as 2 (select 2011 YEAR,1 MONTH, 12101 KONTO, 4674,32 DEBET, 0 KREDIT, to_date('05.06.11','DD.MM.YY') DATE_TR, NULL IND from dual union all 3 select 2011, 6, 12101, -4674,32, 0, to_date('05.06.11','DD.MM.YY'), 'R' from dual union all 4 select 2011, 6, 12182, 4674,32, 0, NULL, 'R' from dual 5 ) 6 SELECT * 7 FROM temp 8 WHERE CASE 9 WHEN To_date('&dt, 'DD.MM.YYYY') > (SELECT MAX(date_tr) 10 FROM temp) THEN To_char(date_tr) 11 ELSE ind 12 END IS NULL; Enter value for dt: 30.06.2011 YEAR MONTH KONTO 4674 DEBET KREDIT DATE_TR I ---------- ---------- ---------- ---------- ---------- ---------- --------- - 2011 6 12182 4674 32 0 R SQL> / Enter value for dt: 30.05.2011 YEAR MONTH KONTO 4674 DEBET KREDIT DATE_TR I ---------- ---------- ---------- ---------- ---------- ---------- --------- - 2011 1 12101 4674 32 0 05-JUN-11 SQL>
-
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?
-
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. '
Maybe you are looking for
-
To increase the performance of the system (Windows XP, Vista, 7 and 8)
Hi all Most people enjoy to keep their work in the computer and working properly, as long as possible. I have provided a few interesting documents that they will help you to keep your system as recent as possible concerning regular maintenance. I am
-
Satellite U400-17Y - how to set up the facial recognition?
I recently bought by Satellite U400-17Y and difficulties to find the way to put in place one of its function, i.e. to Face Recognitiion. Please help me. Thank you.
-
Equium A210 - Question on two 2 hard drives using Vista
I'm looking for some portable refurbished Toshiba and see that some of them (including the title template) have 2 hard drive bays. An individual has a specified 80 GB drive and I am puzzled as to how, if the 80 GB is divided, it can run Vista. I inte
-
How can I connect name BT IDS of devices in a log file by using the Toshiba BT stack
Hello without Microsoft stack, I can't use a lot of freeware programs (BluetoothView.exe, BluetoothCL.exe, BTScanner for Windows), to 'catch up' bluetooth devices in a log file. How can I connect names bt ID/description of the devices in a logfile us
-
What is the best Instagram app to use on a Mac book pro
HHey guy What is the best App Instagram for use with MacBook Pro I downloaded two and they do not have the possibility to edit and publish on your profile