CASE WHEN not working
Hello all,
I need to reclassify some data based on the values in two columns, the logic to do this is:
WHEN CC=X AND DC IS NULL OR DC IS NOT NULL THEN B
WHEN CC IS NULL AND DC IS NOT NULL THEN B
WHEN CC IS NULL AND DC IS NULL THEN NB
This should be a simple CASE WHEN. I've tried to build this logic in all possible ways and results are incorrect! As you can see is not a complicated one,
Please help!
Nayeli
WHEN CC=X AND DC IS NULL OR DC IS NOT NULL THEN B
WHEN CC IS NULL AND DC IS NOT NULL THEN B
WHEN CC IS NULL AND DC IS NULL THEN NB
1 tip,put always in brackets,it is annoying but help logic.
2.try to make it step by step
case WHEN ( CC=X ) AND ( DC IS NULL) OR ( DC IS NOT NULL ) THEN B
else
case when....
else........
be careful
( CC=X ) =1
( DC IS NULL)=2
( DC IS NOT NULL ) =3
u mean (1 and 2) or 3,(1) and (2 or 3) ......
i hope i helped....
http://greekoraclebi.blogspot.com/
///////////////////////////////////////
Similar Messages
-
Count (case when) not working in sql
Hi All,
I am trying to find the count of members for a perticular date range, it seems not working correclty.
Could any one help me out.
here is the query...I am getting same output for all the cases..please help
Select
t
.MemberNbr,t.patcom
count(case
when
datediff(d,
mbrs.DischargeDate,
convert(datetime,convert(varchar(12),t.specificdateofservice),112))
between
-1
and
-365
then t.MemberNbr
else 0
end)as
edvisits365daysprior
count(case
when
datediff(d,
mbrs.DischargeDate,
convert(datetime,convert(varchar(12),t.specificdateofservice),112))
between 1
and 3
then t.MemberNbr
else 0
end)as
edvisits3Days
count(case
when
datediff(d,
mbrs.DischargeDate,
convert(datetime,convert(varchar(12),t.specificdateofservice),112))
between 1
and 30
then t.MemberNbr
else 0
end)as
edvisits30Days
count(case
when
datediff(d,
mbrs.DischargeDate,
convert(datetime,convert(varchar(12),t.specificdateofservice),112))
between 1
and 60
then t.MemberNbr
else 0
end)as
edvisits60Days
count(case
when
datediff(d,
mbrs.DischargeDate,
convert(datetime,convert(varchar(12),t.specificdateofservice),112))
between 1
and 90
then t.MemberNbr
else 0
end)as
edvisits90Days
--,*--membernbr,specificdateofservice,count( membernbr)--, specificdateofservice)as visitcount--, patcom
--Into #Tmp_PPCSEDCnt1
From
stg_tbl_InPatientPrepost Mbrs
join
#Tmp_MCCSEDVisits t
on
mbrs.MemberNbr=t.MemberNbr
--where UPPER(t.MR_Line_Desc) in ('FOP EMERGENCY ROOM - HOSPITAL', 'FOP EMERGENCY ROOM Urgent Care',
--'PROF ER VISITS AND OBSERVATION CARE')
group
by t.MemberNbr,t.patcomYou may replace 0 as NULL and see how it works for you?
eg:
count(case when datediff(d, mbrs.DischargeDate,
convert(datetime,convert(varchar(12),t.specificdateofservice),112))
between -1 and -365 thent.MemberNbr else NULL end)as edvisits365daysprior -
SELECT CASE WHEN not working?
Hello, can't figure out why the following statement continues to return NULL values and seems to not recognize my case when portion?...
INSERT tbl_Main
select OrderID
,(select
case
when (b.OrderValue is null or b.OrderValue = '') then 'Y'
else b.OrderValue
end
from tbl_OrderDetails b where b.OrderID = a.OrderID and b.DetailID = '7')
AS OrderStatus
from tbl_Order a
Thanks in advanced.Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
This is minimal polite behavior on SQL forums.
1. The use of the “tbl-” prefix is a design flaw called “tibbling” and people will laugh at you for it.
2. Do not nest selects inside a select list; the performance stinks.
3. Why do you think “A”, "D” etc are good aliases that will make maintaining this code easier? Noobs do this is match the names of tape drives on old hardware!
4. Why do you think that treating a NULL and an empty string as the same is a good idea? Use a CHECK (order_value <> '').
My guess is you could write this instead:
INSERT INTO Orders
SELECT order_id, COALESCE (D.order_value, 'Y') AS order_status
FROM Order_Details AS D
WHERE D.order_id = Orders.order_id
AND D.detail_id = '7')
AS order_status;
But this still smells bad. A status is a state of being so it has a temporal component. Order details do not usually have an id; the item identifier (EAN, UPC, SKU, or whatever) is used.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
False/True Case is not working. Please Help!
Dear all,
I attached my block diagram, one attachment refers to true case and the other refers to false case.
My program runs like this: when i run the vi , after homing the motor (there is home.vi), DAQ is collecting the values in the while loop, and according to the DAQ's value, motor should run the False/True case but it does not
As a result: true/false case is not working which is located at the outside of the loop(bottom side of the block diagram)
When i put the the True/false inside the Loop(DAQ's loop) , then it is working. But this brings lots of problem, two of them is:
1-) When the DAQ values goes below to "50" then it turns to true case again,
2-) The false case has stop.vi which cause to motor stop every iteration of the loop.
So that is why i put True/False case out of the loop but now it is not working at all.
Please answer, waiting response.
Thank you,
Have a nice day,
Kind Regards.
Attachments:
OutloopTrueMode.pdf 432 KB
OutofLoopNotWorking.pdf 443 KBSalander wrote:
Dear GerdW,
Thank you for reply, You can see my answers written with red.
"As long as the case structure is located outside the loop it will not be called before the loop stops. THINK DATAFLOW!"
- The case structure need to run same time with the loop, because as you can see from the attachments the case structure is also integrated with DAQ values.. loop is continuous till i press the stop button. So what i understand that this case structure will not work because loop is continuous?? Cant we upgrade the vi. or do smthg that it can be able to work same time with the loop??
Kind Regards.
You have to place the case structure inside the while loop ( Any significance is there on placing the case outside the loop? ).
Salander wrote:
Dear GerdW,
Btw. it would be much more useful to attach real pictures or, even better, the VI...
Because most of the people dont have my "motor controller's labview drivers" I attached as a PDF file which is very popular.
Not Really * .png file ( vi snippet ) is much more popular here in Discussion Forum
The best solution is the one you find it by yourself -
"case when not m[1] is present then" outputs ORA-03113
I find that "case when not m[1] is present then" outputs ORA-03113:
Why?
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
select * from dual model
dimension by(0 as d)
measures(1 as m)
rules(
m[any] = case when not m[1] is present then 1 end);
ORA-03113:Below one is alterNative solution.
select * from dual model
dimension by(0 as d)
measures(1 as m)
rules(
m[any] = case when presentv(m[1],1,0) = 0 then 3 end);
D M
0 3I get:
ops$me%DB> select * from dual model
2 dimension by(0 as d)
3 measures(1 as m)
4 rules(
5 m[any] = case when not m[1] is present then 1 end);
select * from dual model
ERROR at line 1:
ORA-03002: operator not implemented
Elapsed: 00:00:00.03
ops$me%DB> select banner from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Productio
NLSRTL Version 10.2.0.4.0 - Production -
BPEl Human Activity Issue - Reject case is not working
Hi All,
I have bpel processs. It is works like this:
It has a human task for approval from manager with ACCEPT or REJECT as outcomes.
Once the manager Accepts the request, the initiator (say applicant) should get a email updating the status as accepted.
And when the request is rejected by manager, then the initiator(say applicant) should get an email updating the status.
The problem is the human activity is working fine for ACCEPT and sending email. But struck up for REJECT outcome. It is waiting for task completion from manager, i mean completion of human activity even though it is completed as the manager rejected it.
Audit activity log when Human activity got REJECTed by manager:
*"waiting for "onTaskCompleted" from "TaskService". Asynchronous callback"*
I tried the below things.
1) Deleted the task form --> saved the process --> closed Jdev --Re-opened JDev and created a new task form. Still the same behavior. Not working for REJECT case.
Can some body help me in figuring out the issue.
I am using SOA suite 10.1.3.1 n JDev 10.1.3.1
Thanks,Hi,
I could figure out the solution to the problem.
The issue was with xquery. I build it wrongly. I could find this from my domain logs.Then I corrected the query. Now it is working fine.
Thanks,
Irfan khan -
Case tatement not working within a cursor
I am having a problem getting the case statement to work within a cursor in a store procedure in our 2008 r2 environment. Below is the cursor that I'm referring too. Any suggestions would be greatly appreciated.
SET NOCOUNT ON;
DECLARE @part_id as int, @WAREHOUSE_ID AS varchar(80), @SAFETY_STOCK_QTY AS int;
DECLARE parts_cursor CURSOR FOR
select part_id ,WAREHOUSE_ID, coalesce(SAFETY_STOCK_QTY,0) from PART_WAREHOUSE where Part_ID in (SELECT distinct #FLINES03.Part from #FLINES03)
OPEN parts_cursor
FETCH NEXT FROM parts_cursor
INTO @part_id, @WAREHOUSE_ID, @SAFETY_STOCK_QTY
WHILE @@FETCH_STATUS = 0
BEGIN
CASE @WAREHOUSE_ID
WHEN 'AAA' THEN UPDATE #FLINES03 SET WHS1_SS_QTY = @SAFETY_STOCK_QTY WHERE #FLINES03.PART = @part_id AND #FLINES03.WHS1 = @WAREHOUSE_ID
WHEN 'BBB'THEN UPDATE #FLINES03 SET WHS2_SS_QTY = @SAFETY_STOCK_QTY WHERE #FLINES03.PART = @part_id AND #FLINES03.WHS2 = @WAREHOUSE_ID
WHEN 'CCC' THEN UPDATE #FLINES03 SET WHS3_SS_QTY = @SAFETY_STOCK_QTY WHERE #FLINES03.PART = @part_id AND #FLINES03.WHS3 = @WAREHOUSE_ID
END
FETCH NEXT FROM parts_cursor INTO @part_id, @WAREHOUSE_ID, @SAFETY_STOCK_QTY
END
CLOSE parts_cursor
DEALLOCATE parts_cursorCASE is an expression, not a statement. It means you can not execute code. You need to change your code to IF statements, e.g.
IF @WAREHOUSE_ID = 'AAA'
UPDATE ....
IF
UPDATE ...
Also, what is the purpose of using cursor? Can you provide the whole picture of what you're trying to achieve?
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
CLOB with case statement not working getting error
Can anyone help on this
I write this sql
select Case when to_clob(PROPERTY) = 'is_intradesk=Y' then 'Internal' end
from JPM_CP;
Where PROPERTY column is clob column and its giving the error "ORA-00932: inconsistent datatypes: expected - got CLOB"
Is it not possible to use clob columns with case or decode !Its working but it does not fulfill my purpose
In you answer it is looking for position right! means, does the column contain the value('Intradesk=Y' ) or not. means
I am looking for exact match with CLOB column values, that is Clob column(PROPERTY) contains the exact value that value which I am comparing with i.e 'Intradesk=Y'
I need this
select * from table where clob_column = 'value' (exact).
Edited by: sajalkdas on Feb 4, 2011 3:28 PM -
MDX simple case statement not working?
hi all - any idea what is wrong with this MDX statement? it is returning blank. I am trying to add a calculated measure using the below code but it is not working. thanks for the help.
CASE WHEN [Accounts].[Account Name].CURRENTMEMBER = "Cash" THEN
([Dates].[Hierarchy].currentMember.lastChild, [Measures].[Measures].[Amount]) ENDIf you are checking for the 'Cash' member of the Account Name hierarchy, do you need to do something like this?
CASE WHEN [Accounts].[Account Name].CURRENTMEMBER IS [Accounts].[Account Name].[Cash] THEN([Dates].[Hierarchy].currentMember.lastChild, [Measures].[Measures].[Amount]) END
Regards,
MrHH -
Case statement Not working with Oracle version 10g
Below is code , which works on 11r2 but not on 10g.
declare
v1 VARCHAR2(200);
begin
select version into v1 from DBA_REGISTRY WHERE COMP_NAME LIKE '%Catalog Views%';
CASE
WHEN v1 like '10.2%' THEN
DBMS_OUTPUT.PUT_LINE('it is 10.2');
dbms_streams_auth.grant_admin_privilege('GGADMIN');
WHEN v1 like '11.1%' THEN
DBMS_OUTPUT.PUT_LINE('it is 11.1');
dbms_streams_auth.grant_admin_privilege('GGADMIN');
EXECUTE IMMEDIATE 'grant become user to GGADMIN';
WHEN v1 like '11.2.0.3%' THEN
DBMS_OUTPUT.PUT_LINE('it is 11.2.0.3');
dbms_goldengate_auth.grant_admin_privilege('GGADMIN');
END CASE;
end;
/I dont know when i run code in 10.2 it still looks for dbms_goldengate_auth
and error out.
dbms_goldengate_auth.grant_admin_privilege('GGADMIN');
ERROR at line 18:
ORA-06550: line 18, column 1:
PLS-00201: identifier 'DBMS_GOLDENGATE_AUTH.GRANT_ADMIN_PRIVILEGE' must be declared
ORA-06550: line 18, column 1:
PL/SQL: Statement ignoredif I comment dbms_goldengate_auth it returns perfect result.
it is 10.2
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.03Is there any other way around ????
Edited by: 949509 on Jan 27, 2013 6:57 PM949509 wrote:
Can you please tell me How i can execute dynamic sql via execute immediate.In a very simialr was as you did the grant of become user in your code. SOmething like:
declare
v1 VARCHAR2(200);
l_grant_str VARCHAR2(1000);
begin
select version into v1 from DBA_REGISTRY WHERE COMP_NAME LIKE '%Catalog Views%';
CASE
WHEN v1 like '10.2%' THEN
DBMS_OUTPUT.PUT_LINE('it is 10.2');
l_grant_str := 'dbms_streams_auth.grant_admin_privilege(''GGADMIN]'')';
WHEN v1 like '11.1%' THEN
DBMS_OUTPUT.PUT_LINE('it is 11.1');
l_grant_str := 'dbms_streams_auth.grant_admin_privilege(''GGADMIN'')';
EXECUTE IMMEDIATE 'grant become user to GGADMIN';
WHEN v1 like '11.2.0.3%' THEN
DBMS_OUTPUT.PUT_LINE('it is 11.2.0.3');
l_grant_str := 'dbms_goldengate_auth.grant_admin_privilege(''GGADMIN'')';
END CASE;
execute immediate l_grant_str;
end;John -
Case statement not working in rpd
Hi Gurus,
I am giving case statement for the exchange rate column#1 from original exchange rate column , the data of column is like
0.0
0.0
0.1
0.2
1.2
1.3
1.4
so here i dont want 0.0 instead of that i want 1.0 so whenever in next derived column i will calculate it would be this derived exchange rate#1 * inv amt = desired amt
for the same I used different diff. case statement but still 0.0 is not going , I am giving like
1) CASE WHEN BookingsBacklog."Fact USJ Sales Billing"."Loc Exchange Rate" = 0.0 THEN BookingsBacklog."Fact USJ Sales Billing"."Loc Exchange Rate" * 1.0 ELSE BookingsBacklog."Fact USJ Sales Billing"."Loc Exchange Rate" END
2) CASE WHEN BookingsBacklog."Fact USJ Sales Billing"."Loc Exchange Rate" = 0.0 THEN 1.0 ELSE BookingsBacklog."Fact USJ Sales Billing"."Loc Exchange Rate" END
nothing is working , result remains same, any quick help would be apprciated
Thanks,Once again, could you write all information, like I described here my example.
When tried the same it works.
TABLE.COLUMN1 is from dimension.
TABLE.COLUMN1 is DOUBLE in the physical layer (in Oracle it is NUMBER(8,2)) and view/data gives:
TABLE.COLUMN1
12.99
0.00
0.20
In the RPD I made new logical columns.
EXPR:
CASE WHEN "Presentation area".TABLE.COLUMN1 = 0.0 THEN 1.0 ELSE "Presentation area".TABLE.COLUMN1 END
EXPR2:
CASE WHEN "Presentation area".TABLE.COLUMN1 = 0 THEN 1 ELSE "Presentation area".TABLE.COLUMN1 END
Test in Answers:
COLUMN1----EXPR----EXPR2
12.99---------12.99----12.99
0.00-------------1.0--------1.0
0.20------------0.20------0.20
I leaved data format on the column properties as default (override default data format not checked).
I don't see where is the problem.
Regards
Goran
http://108obiee.blogspot.com -
HP Pavilion 500 PC computer case ports not working
I left my computer on for about two weeks. Most likely it overheated the computer case. Yesterday, I decided to shut down the computer for it to update.Next morning I turn on the computer and my mouse and keyboard didn't work. I can turn on the power for my computer, but my computer doesn't respond to mouse and keyboard. The monitor also can't find the computer saying how there's no signal. I tried restarting the computer multiple times through the power button, unplugging the usb cords and the cord for the monitor multiple times and tested the mouse and keyboard on a different computer. When I connect my mouse to the computer it does not show the red optic light on the bottom, but it does and works on another computer. The keyboard also works on another computer. I tried taking out all of the cords off the computer case and taking of the power cord of it and waiting, putting the cords back in and trying again, but i did not work. I tried to go in BIOS, but I am not sure whether or not I am pressing the right key combination or because of the fact the computer is not responding to me pressing the keys on the computer. Also, before I shut down the computer I noticed the computer was reacting slow to me clicking and closing windows sometimes and I do not know if that would be related to the problem. I can't access my computer because it will not react to the monitor, mouse and keyboard. It worked fine when I kept it on and previously before when I shut it down.
Thanks
This question was solved.
View Solution.The little beep that should be occuring lets you know that your computer has completed the Power On Self Test or POST. This test is a basic test of all hardware. Usually if a component like the RAM has gone bad there will be a series of beeps that communicates what has gone bad. In my experience there are only two reasons why there would be no post code. The first would be that the power supply has gone bad, no power means no POST. However, your fan comes on, indicating that there is still power. Which means the second and far more severe case is more likely here. Your motherboard is most likely toast. I know that is the worst possible prognosis, but I think that it is accurate here. Sorry.
I work on behalf of HP, but my opinions are my own.
Please click the "Thumbs up + button" if I have helped you and click "Accept as Solution" if your problem is solved. If both apply......do both. -
[BUG] "Open declaration" in some cases does not work
If object name has the different register of letters then "Open declaration" in context menu does not work. But in the same case "Popup describe" in context menu works fine.
Oracle SQL Developer 3.1.07
Version 3.1.07
Build MAIN-07.42
Edited by: Roman on 19.04.2012 3:48I also would like to see some explanation when is it planned to make this feature work :)
-
Process validation for test case is not working
I' am using SQL Developer EAR 3.0.02.83. The is a test case defined which uses "Query returns rows" with Select count(*) from dual;
It should return a row an that way fulfill the test.
but when running the testcase I get the result ERROR due to:
Query returns rows not succesful: null
How can I find the reason? Is this a bug?
Even other types of validation do not work, they always give null and the overall result ERROR.Thanks for your reply. Unfortunately our procedure returns in some cases null values, so that a unit test is not possible.
I need to ckeck the results of the function, but not to compare them with fixed values, rather something like {VALUE$} LIKE 'x%Y'.
I'am afraid there is no solution.
When can I hope the relaese version to be available? -
HP PRime Calculator - RPN active - 'Get Home' in CAS do not work
Firmware version : 20150617 v8151 If I have RPN active in home view, when in CAS I press Menu->Get Home, the list of values that are shown are of the Textbook setting.The virtual calculator has the same problem. RPN Screen: CAS Screen:
Hi,
I would suggest you try:
http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/forum.cgi
there is some discussion there about about starting a bug reporting forum. A feature request section would be a useful part of that too.
You can also try the comp.sys.hp48 newsgroup. The GoogleGroups link:
https://groups.google.com/forum/#!forum/comp.sys.hp48
Regards.
Note: I do not work for HP, I just like playing with calculators :-)
Maybe you are looking for
-
Time Machine backup causes network connections to fail
We have a simple network with OS X Server (10.6.4) + a 10.6.4 Mac client and a Windows XP client. For some time we have been suffering sporadic drop outs of the network connection from the iMac OS X client to the server: the shared drives just disapp
-
HOW TO CREATE A KEYWORD SEARCH FORM
Hi, I'm creating a image gallery and I'm about 90% complete. One of my final objectives is to create a keyword search for my image gallery. I have 4 fields in my DB, (id,image,description,keywords) I want to be able to enter keywords into the text
-
Exporting PDF results in inconsistent Colours in inDesign
Hi Everyone! I'm trying to export a document for digital print which consists primarily of a embeded PSD. I have two spreads, one with objects on top of the PSD file and one without. The PSD backgrounds on these two spreads are nearly identical, but
-
Problem adding an image to the display list
I'm trying to create a component to add images to a Panel (id=hbox). I seem to be loading the images successfully (because the trace statement works), but can't add them to the display. I'm using the following line of code, but getting an error: hbox
-
I am updating pld of purchase order.I want attach a document specifying certain conditions.This document should be issued time a po is created.How to attach this document ? Regards, Dilip Kumbhar