Re : Multiple values resut of CASE statement
Hello All,
Hope all is well. I was trying to basically return multiple values if a certain value 'X' was passed. for example,
select
case T1.C1
when 'X' then ('XX','YY')
else T1.C1
end
from T1
but I am getting error. I am unable to figure out as to how do you get multiple values out of a single value in SQL. I will then be passing this multiple values as filter in where clause. For example,
where ('XX','YY') in T2.C1
Thanks in advance and let me know if I have missed on something.
- Sam
Hello Frank,
Thanks for the response. You are correct , when value happens to be 'X' then I want to pass ('XX','YY') ( result of sub query) to the outer query. In essense, I want to pass multiple values to the outer query when a specific value is 'X'.
For Example,
I want query to be
select T1.C1,T1.C2
from T1
where T1.C1 in ('XX','YY') // When the value of T2.C1 happens to be 'X'
Let me know if I am clear here ..... The query throws no syntax error but does not return any data ...when there is data for T1.C1 in ('XX','YY') in DB. If I ran the query as is as posted above , query does return data but when it is ran as sub query as mentioned in previous posts , the query does not return any data !!!! ..thats where I am puzzled.
Thanks again,
Sam
Edited by: user588790 on Jan 29, 2009 12:38 PM
Similar Messages
-
Assigning value inside a case statement
Hi friends
iam using the below code and can any one tell me why even after assigning the value in the case statement it coming out of it.
code
data :
p1(1) type n.
case p1.
when '0'.
write 'sunday'.
p1 = 1.
when '1'.
write 'monday'.
p1 = 2.
when others.
write 'invalid day'.
endcase.
output.
sunday
can any one tell me why it is coming out of the case statement even iam assigning p1 = 1This is happening b'cause u have already in the when clause where u r setting the value of the variable that is controlling ur case..endcase statement.To meet ur requirement u need to trigger the case..endcase statement again as shown below:
data :
p1(1) type n.
do 3 times.
case p1.
when '0'.
write 'sunday'.
p1 = 1.
when '1'.
write 'monday'.
p1 = 2.
when others.
write 'invalid day'.
endcase.
enddo. -
Problem to identify values in a case statement.
Hi Friends,
Total number of records in my report should be divided by 5 and to be alloted into 5 grades in Grade column.
This is what I have done so far in my report with following layout.
S.No - Col A - Col B - Col C - Grade ( Colums A,B,C will be hidden in Report)
*****Column C will have only 5 values at max ( 0.0, 0.2, 0.4, 0.6, 0.8).The below example is for 6 records in a report.The same will be applied for 7,8,9,10 records.
In column A: MAX(cast(RCOUNT(1) AS DOUBLE))/5 ( Ex : 6/5 = 1.2)
In Column B: Truncate(MAX(cast (RCOUNT(1) as double)/5), 0) ( Ex : 6/5 = 1.0)
In Column C: Col A- Col B ( EX:1.2 - 1.0 =0.2)
(MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0))
Now In Grade coulum I want to use this column C to Grade the records with case statements in it.
I am trying to use the following case statement for Grade Coulmn
Case
when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.0 then .........
when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.2 then .............
when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.4 then .............
when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.6 then ........
when (MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0)) = 0.8 then .....
end
Case statement works gud for 0.0 but not for other 4 values.
It is unable to identify other 4values.
Please tell me, how can I make case statement work for all values in above scenario.
Thanks in Advance,
Varsha.
Edited by: Varsha on Nov 28, 2010 6:23 PMIn column A: MAX(cast(RCOUNT(1) AS DOUBLE))/5 ( Ex : 6/5 = 1.2)
In Column B: Truncate(MAX(cast (RCOUNT(1) as double)/5), 0) ( Ex : 6/5 = 1.0)
In Column C: Col A- Col B ( EX:1.2 - 1.0 =0.2)
(MAX(cast(RCOUNT(1) AS DOUBLE))/5 - Truncate(MAX(cast (RCOUNT(1) as double)/5), 0))Change the formula a bit by adding the by dim value for the MAX column.
Column A: MAX(cast(RCOUNT(1) AS DOUBLE) by DimTable.Column)/5
Column B: Truncate(MAX(cast (RCOUNT(1) as double) by DimTable.Column)/5, 0)
Column C: MAX(cast(RCOUNT(1) AS DOUBLE) by DimTable.Column)/5 - Truncate(MAX(cast (RCOUNT(1) as double) by DimTable.Column)/5, 0)
now write a case statement on top column c, based on your logic every 5th record will have a value 0.0
Note: Dimtable.column is the table.column for which the row count is taken.
Thanks,
Vino -
Return multiple values from a function to a SELECT statement
I hope I've provided enough information here. If not, just let me know what I'm missing.
I am creating a view that will combine information from a few tables. Most of it is fairly straightforward, but there are a couple of columns in the view that I need to get by running a function within a package. Even this is fairly straightforward (I have a function named action_date in a package called rp, for instance, which I can use to return the date I need via SELECT rp.action_date(sequence_number).
Here's the issue: I actually need to return several bits of information from the same record (not just action_date, but also action_office, action_value, etc.) - a join of the tables won't work here as I'll explain below. I can, of course, run a separate function for each statement but that is obviously inefficient. Within the confines of the view select statement however, I'm not sure how to return each of the values I need.
For instance, right now, I have:
Table1:
sequence_number NUMBER(10),
name VARCHAR(30),
Table2:
Table1_seq NUMBER(10),
action_seq NUMBER(10),
action_date DATE,
action_office VARCHAR(3),
action_value VARCHAR(60),
I can't simply join Table1 and Table2 because I have to do some processing in order to determine which of the matching returned rows I actually need to select. So the package opens a cursor and processes each row until it finds the one that I need.
The following works but is inefficient since all of the calls to the package will return columns from the same record. I just don't know how to return all the values I need into the SELECT statement.
CREATE VIEW all_this_stuff AS
SELECT sequence_number, name,
rp.action_date(sequence_number) action_date,
rp.action_office(sequence_number) action_office,
rp.action_value(sequence_number) action_value
FROM table1
Is there a way to return multiple values into my SELECT statement or am I going about this all wrong?
Any suggestions?
Thanks so much!Hi,
What you want is a Top-N Query , which you can do using the analytic ROW_NUMBER function in a sub-query, like this:
WITH got_rnum AS
SELECT action_seq, action_dt, action_office, action_type, action_value
, ROW_NUMBER () OVER ( ORDER BY action_date
, action_seq
, action_serial
) AS rnum
FROM table2
WHERE action_code = 'AB'
AND action_office LIKE 'E' -- Is this right?
SELECT action_seq, action_dt, action_office, action_type, action_value
FROM got_rnum
WHERE rnum = 1
;As written, this will return (at most) one row.
I suspect you'll really want to get one row for each group , where a group is defined by some value in a table to which you're joining.
In that case, add a PARTITION BY clause to the ROW_NUMBER function.
If you'd post a little sample data (CREATE TABLE and INSERT statements), I could show you exactly how.
Since I don't have your tables, I'll show you using tables in the scott schema.
Here's a view that has data from the scott.dept table and also from scott.emp, but only for the most senior employee in each department (that is, the employee with the earliest hiredate). If there happens to be a tie for the earliest hiredate, then the contender with the lowest empno is chosen.
CREATE OR REPLACE VIEW senior_emp
AS
WITH got_rnum AS
SELECT d.deptno
, d.dname
, e.empno
, e.ename
, e.hiredate
, ROW_NUMBER () OVER ( PARTITION BY d.deptno
ORDER BY e.hiredate
, e.empno
) AS rnum
FROM scott.dept d
JOIN scott.emp e ON d.deptno = e.deptno
SELECT deptno
, dname
, empno
, ename
, hiredate
FROM got_rnum
WHERE rnum = 1
SELECT *
FROM senior_emp
;Output:
. DEPTNO DNAME EMPNO ENAME HIREDATE
10 ACCOUNTING 7782 CLARK 09-JUN-81
20 RESEARCH 7369 SMITH 17-DEC-80
30 SALES 7499 ALLEN 20-FEB-81
By the way, one of the conditions in the query you posted was
action_office LIKE 'E'which is equivalent to
action_office = 'E'(LIKE is always equivalent to = if the string after LIKE doesn't contain any wildcards.)
Did you mean to say that, or did you mean something like this:
action_office LIKE 'E%'instead? -
Wildcard value in case statement
Hi,
How would I use a wildcard value in my case statement. I evaluate a string value of numbers and try to do this "1234***" but it doesn't work. "***" represents any 3 number.
Please advise.
Thanks
dphan128You could mark one of the cases as "Default", and that case will execute when no others match. If you want to explicitly run that case only if the first 4 numbers are "1234", then you need to pre-process the string.
See here for the same exact question. -
Using Field/Column Date Value In Case Statement
I have code that the first part works (the part that evaluates null). However, it appears the second part doesn't work. The error I get is:
Data Value out of range
Can you use the a table column value in a Case statement? What I'm trying to do is: where all mbr06..values are 12/31/9999, then null; if mbr06.. values are equal to or less than today's date, then put the value in mbr02.mbr02_cancel_proc_date..
Note, the table MBR02 does have dates that go back as far as 11/17/1858..could that be an issue?
Thanks for any assistance..
cast((case
when mbr06.mbr06_exp_date = to_date('31-dec-9999') then null
when mbr06.mbr06_exp_date <= sysdate then mbr02.mbr02_cancel_proc_dateThe error is due to the CAST, not to the CASE.
Cause: Value from cast operand is larger than cast target size.Post at least the whole cast ...
Max
http://oracleitalia.wordpress.com -
I can actually pass multiple values in the IN statement of select query using multiple dictionary fields in the data retrieval rule of the AFC in Cisco cloud portal like
#dictionary.field1# = 1 and
#dictionary.field2#=2
select col1,col2 from table1 where col3 in (#dictionary.field1#,dictionary.field2#).
but I want to pass mutiple values in a single field as
#dictionary.field1#=1,2
select col1,col2 from table1 where col3 in (#dictionary.field1#) and the query gives no data because it is taking as '1,2' instead of '1','2'.
Please give the solution for passing multiple values in a single variable to use in IN operator of WHERE clauseOk, I now understand what you are trying to do. Unfortunately, you cannot inject parts of a SQL statement into a DDR through a dictionary field, which always represents a specific value (the comma in your case is attempting injection of a SQL construct to refer to multiple values). One possible solution is to arbitrarily consolidate your list of values using a delimiter that you know will not be in the values themselves such as a colon (:). Let's use 3 values as it serves as a better example.
Set your dictionary field to a single reference to all 3 values of interest, say 'a', 'b', 'c' as:
:a:b:c: (you can use javascript to create this consolidated dictionary field)
Now your query would look something like the following:
select col1,col2 from table1 where #dictionary.field1t# like '%:'+col3+':%'
This should achieve the desired result. -
Trying to use greater than in a case statement
What is the correct way to write this case statement?
Case
F.NextOrder2
> F.CutOff
Then
Else F.NextOrder2
as NextOrder3You're missing END, e.g.
CASE when F.NextOrder2 > F.CutOff then '' else cast(F.NextOrder2 as varchar(100)) end as NextOrder3
All values in the CASE statement must be of the same data type.
See this blog post why
SQL Server Case/When Data Type problems
Premature optimization is the root of all evil in programming. (c) by Donald Knuth
Naomi Nosonovsky, Sr. Programmer-Analyst
My blog -
How do I pass multiple values from a text box to an update statement
I hope this does not sound to lame. I am trying to update multiple values Like this:
Code|| Computer Desc || Computer Price || Computer Name
SEL1 || Apple macbook || 1564 || Apple Macbook Basic
SEL2 || Dell 630 || 1470 || Dell Latitude
I want to change all six values at once in one update statement based on the Code, I can't find a good tutorial/example to help me.
Can anyone point me in the right direction?
Thanks so much,
LauraYou can do conditional updates with decode or case statements e.g.
SQL> create table t as
2 select 'SEL1' as code, 'Apple macbook' as comp_desc, 1564 as comp_price, 'Apple Maxbook Basic' as comp_name from dual union
3 select 'SEL2', 'Dell 630', 1470, 'Dell Latitude' from dual
4 /
Table created.
SQL>
SQL> update t
2 set comp_desc = CASE code WHEN 'SEL1' THEN 'Test1' Else 'Test2' END,
3 comp_price = CASE code WHEN 'SEL1' THEN 1234 Else 2345 END,
4 comp_name = CASE code WHEN 'SEL1' THEN 'Test1 Name' Else 'Test2 Name' END
5 /
2 rows updated.
SQL>
SQL> select * from t
2 /
CODE COMP_DESC COMP_PRICE COMP_NAME
SEL1 Test1 1234 Test1 Name
SEL2 Test2 2345 Test2 Name
SQL> -
Help With A Case Statement With Multiple Variables
I apologize if this is the incorrect Forum for this type of question, but it was the closest one that I could find. I'm pretty new with SQL and am stuck on this issue. I have roughly 26 dates that I need to compare to one another. Each date is tied to a step code. I also have a Stop value that is tied directly to the "max date" of the step codes. So, I need to compare 30 dates against one another to 1st - ID the max date; 2nd - ID if the Stop value is correct; 3rd - if the stop value is incorrect, identify what the correct value would be.
At first, this seemed like it wouldn't be that hard. I wrote a query that found the max date for each step code. Then I realized that multiple step codes could have the same date. So, I tried using this case statement, but I did not get the expected results. Is there a more efficient way of getting what I need? This code seems like it's not necessary and probably the source of my issue.
CASE
WHEN FS25.ACTUAL_COMPLETION_DATE > FS.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS1.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS2.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS3.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS4.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS5.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS6.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS7.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS8.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS9.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS10.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS11.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS12.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS13.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS14.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS15.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS16.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS17.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS18.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS19.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS20.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS21.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS22.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS23.ACTUAL_COMPLETION_DATE AND FS25.ACTUAL_COMPLETION_DATE > FS24.ACTUAL_COMPLETION_DATE AND L.FORECLOSURE_STOP_CODE <= '8' THEN '9'
ELSE 'UH OH'
END AS "CHANGE FC STOP TO"
Any assistance is appreciated!I think Igor pointed out a working solution before.
Applying it at your examples (you missed the operator after STOP_CODE, I assume it =):
CASE
WHEN FS25 = GREATEST(FS25, FS24, FS23) AND STOP_CODE = '9' THEN '9'
ELSE 'UH OH'
END AS 'CHANGE STOP CODE TO'
{code}
Be careful at the second example. You are checking:
{code:sql}
FS25 > FS24 OR FS25 IS NOT NULL AND FS24 IS NULL AND FS25 > FS23
OR
FS25 IS NOT NULL AND FS23 IS NULL AND STOP_CODE = '9'
{code}
Remember that AND has higher priority among operators than OR so if FS25 is greater than FS24 and FS23 the condition will be true even if STOP_CODE is not equal 9.
Regards.
Al -
CASE Statement in Where Condition with Multi Valued parameter in SSRS
Hi All,
I am little confused while using CASE statement in Where condition in SSRS. Below is my scenario:
SELECT
Logic here
WHERE
Date IN (@Date)AND
(CASE
WHEN NAME LIKE 'ABC%' THEN 'GROUP1'
WHEN ID IN ('123456', '823423','74233784') THEN 'GROUP2'
WHEN ABC_ID IS NULL THEN 'GROUP3'
ELSE 'GROUP4'
END ) IN (@GROUP)
So above query uses WHERE condition with CASE statement from @GROUP parameter. I want to pass this parameter as multi- valued parameter and hence I have used CASE statement IN (@GROUP).
For @Date one dataset will pass the available and default values and
for @GROUP parameters, another dataset will pass the available and default values.
But this is not working as expected. Please suggest me where I am making mistake in the query.
Maruthu | http://sharepoint-works.blogspot.comHi Maruthu,
According to your description, I create a sample report in my local environment. It works as I expected. In your scenario, if the selected values from the Date parameter contains some of the Date field values, the selected values from the GROUP parameter
contains some of GROUPS (‘GROUP1’,’GROUP2’,’GROUP3’,’GROUP4’) and the corresponding when statement is executed , then the dataset returns the corresponding values.
In order to trouble shoot this issue, could you tell us what results are you get and what’s your desired results? If possible, you can post the sample data with sample dataset, then we can make further analysis and help you out.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Case statement in a multiple query
Hi everyone,
This is my first time to use case statement in a multiple query. I have tried to implement it but i got no luck.. Please see below
set define off
SELECT g.GROUP_NAME as Market
,t.NAME as "Template Name"
,t.TEMPLATE_ID as "Template ID"
,(SELECT created
FROM material
where template_id = t.template_id) as "Date Created"
*,(SELECT DESTINATION_FOLDER_ID,*
CASE DESTINATION_FOLDER_ID
WHEN NULL THEN 'Upload'
ELSE 'HQ'
END
from log_material_copy
where destination_material_id in (select material_id
from material
where template_id = t.template_id ))as "Origin"
,(select material_id
from log_material_copy
where destination_material_id in (select material_id
from material
where template_id = t.template_id)) as "HQ/Upload ID"
,(SELECT COUNT (mse.ID)
FROM MATERIAL_SEND_EVENT mse, material m, creative c
WHERE mse.MATERIAL_ID = m.MATERIAL_ID
AND mse.MATERIAL_TYPE_ID = m.MATERIAL_TYPE_ID
AND m.ASSET_ID = c.id
AND c.TEMPLATE_ID = t.TEMPLATE_ID) as Sent
,(SELECT COUNT (de.ID)
FROM download_event de, material m, creative c
WHERE de.MATERIAL_ID = m.MATERIAL_ID
AND de.MATERIAL_TYPE_ID = m.MATERIAL_TYPE_ID
AND m.ASSET_ID = c.id
AND c.TEMPLATE_ID = t.TEMPLATE_ID) as Download
,(SELECT 'https://main.test.com/bm/servlet/' || 'UArchiveServlet?action=materialInfo&materialId=' || DESTINATION_MATERIAL_ID || '&materialFolderId=' || DESTINATION_FOLDER_ID
from log_material_copy
where destination_material_id in (select material_id
from material
where template_id = t.template_id)) as "URL to template on MPC layer"
--, t.AVAILABLE_FOR_TRANSFER as "Available for transfer"
FROM template t, layout l, groups g
WHERE t.LAYOUT_ID = l.LAYOUT_ID
AND l.ORGANIZATION_ID = g.IP_GROUPID
AND g.IP_GROUPID in ( 1089, 903, 323, 30, 96, 80, 544, 1169, 584, 785, 827, 31, 10, 503, 1025 )
ORDER BY g.GROUP_NAME ASC;
The one in bold is my case statement.. Please let me know what is wrong with this.
Regards,
JasI think you're getting the idea, but:
You're still selecting 2 columns in the (scalar) subquery. Did you read the link I posted for you?
"a) scalar subqueries - *a single row, single column query that you use in place of a "column"*, it looks like a column or function."
You must move that query outside, join to template.
Something like:
NOT TESTED FOR OBVIOUS REASONS SO YOU'LL PROBABLY NEED TO TWEAK IT A BIT
select g.group_name as market,
t.name as "Template Name",
t.template_id as "Template ID",
m.created as "Date Created",
lmc.destination_folder_id,
case lmc.destination_folder_id
when null then 'Upload'
else 'HQ'
end as "Origin"
(select material_id
from log_material_copy
where destination_material_id in
(select material_id
from material
where template_id = t.template_id)) as "HQ/Upload ID"
(select count(mse.id)
from material_send_event mse, material m, creative c
where mse.material_id = m.material_id
and mse.material_type_id = m.material_type_id
and m.asset_id = c.id
and c.template_id = t.template_id) as sent
(select count(de.id)
from download_event de, material m, creative c
where de.material_id = m.material_id
and de.material_type_id = m.material_type_id
and m.asset_id = c.id
and c.template_id = t.template_id) as download
(select 'https://main.test.com/bm/servlet/' ||
'UArchiveServlet?action=materialInfo&materialId=' ||
destination_material_id || '&materialFolderId=' ||
destination_folder_id
from log_material_copy
where destination_material_id in
(select material_id
from material
where template_id = t.template_id)) as "URL to template on MPC layer"
--, t.AVAILABLE_FOR_TRANSFER as "Available for transfer"
from template t
, layout l
, groups group by
, MATERIAL M
, LOG_MATERIAL_COPY LMC
where t.layout_id = l.layout_id
and l.organization_id = g.ip_groupid
and M.TEMPLATE_ID = t.template_id
and LMC.destination_material_id in ( select material_id
from material
where template_id = t.template_id
and g.ip_groupid in (1089,
903,
323,
30,
96,
80,
544,
1169,
584,
785,
827,
31,
10,
503,
1025)
order by g.group_name asc; -
Print out a column value only if another column has a specific value (CASE Statement)
Hello all,
I tried many hours to find a solution for the following request but wasn't successful. Maybe you could help me.
I've using the already existing SQL Views in Microsoft Service Manager to do some basic reporting about my tickets.There is no closed date in the activity tickets so I decided to print out the lastmodified timestamp when the status is "closed".
That's my query:
SELECT DISTINCT
dbo.DisplayStringView.DisplayName AS Status,
CASE WHEN dbo.DisplayStringView.DisplayName = 'Closed' THEN dbo.DisplayStringView.LastModified ELSE 'NO CLOSED Date' END AS ClosedDate
FROM dbo.MTV_System$WorkItem$Activity$ManualActivity LEFT OUTER JOIN
dbo.DisplayStringView ON dbo.MTV_System$WorkItem$Activity$ManualActivity.Status_8895EC8D_2CBF_0D9D_E8EC_524DEFA00014 = dbo.DisplayStringView.LTStringId
Unfortunatelly I'm not getting the value from dbo.DisplayStringView.LastModified. SQL outputs that it is not possible to convert the string to date/time.
I think there is a problem with the CASE statement in combination with a value select.
Any ideas how to print out a column value only if another column has a specific value?I think it is the other way if you want the missing date shown as a string.
CASE
WHEN
dbo.DisplayStringView.DisplayName
=
'Closed'
THEN
Convert( varchar(10),dbo.DisplayStringView.LastModified
, 101) ELSE
'NO CLOSED Date'
END
AS
ClosedDate -
Handling Exceptions with case statement - convert Exception to int value
Hi,
I'm developing a web app, with servlets.
I'm catching Exceptions in my servlets, for example I would like a user to insert data into a form. If the data cannot be converted into a integer value a java.lang.NumberormatException is thrown.
I would like to catch this and then create a message giving a more specific clue to what happened. Unfortunatly it's possible that other exceptions could be caught, so I want to be able to check which type of Exception has been caught.
I started writing a getErrorMessage(int Code) class. The method has a case statement which just checks the code and return the appropriate message.
This worked well for SQL exceptions as they provide a getErrorCode method. But I was wondering is there any way to convert other Exceptions such as
java.lang.NumberormatException into an integer value?
CheersExceptions have their types (classes) and messages (and maybe an embedded exception). That is, they have much richer internal status then an integer.
Why should they be "converted" to integers?
FLAME on
Gone are the days of good old errno.
FLAME off -
Help with multiple case statements
Hello,
I am new to BO. I am on XI 3.0. SQL 2005. In Designer, I am trying to create a measure in a financial universe that would end up being multiple case statements within one select. This is what I tried to do, but it doesn't work with the two case statements. Can I use an ELSE leading into the second CASE WHEN somehow? How can I accomplish this? Sorry for my ignorance!
CASE WHEN dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month = 12 THEN dbo.ClientBudgetMonth.Stage1Sales END
CASE WHEN dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month = 11 THEN dbo.ClientBudgetMonth.Stage1Sales END
Any Suggestions?
Thanks,
HollyHolly,
I don't know enough about your data or requirement to provide a solution, however, the construct that you post will not work because it causes you to build an object with multiple case statements when only one case statement per object is permitted. From what I see in your code I would be inclined to combine the two statements into one as such:
CASE WHEN dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month in (11,12) THEN dbo.ClientBudgetMonth.Stage1Sales else null END
Thanks,
John
Maybe you are looking for
-
What do I do if the screen turned black with red line across it and it wont resod?
I have tryed everything i could think of but it still wont wotk!!!!!!!!!!!
-
Help! do not want to loose music on my iPod by syncronizing it!
Hello, I got a brandnew iPod for christmas from my dad and now I'm ready to drop it out the window! The problem is my dad bought some music for me too, but he just uploadet it on my iPod and deleted the original files afterwards (means: I do have tha
-
My printer will only print the boarders of a document.
It wont print the information on documents.I've tried two search engines to do it(firefox and internet explorer).Also,I've reduced the security on them.I've even gone down the library to print other stuff off,with noproblem!Thankyou for any help in
-
EC-PCA controlling area settings - Store transaction currency
Hi Reviewing controlling area settings I found that ckeck "store transaction currency " is off ... could I activate (set on) in a productive client that already has postings ?? This could bring any problems? Or It would be better to activate it at b
-
Converting files to suit itunes
Hey there, I hope someone out there can help me, I used to have a sony music player and have quite a collection of atrac music files, now i have seen the light and have just aquired an ipod.....i guess you know where this is going now....can anyone t