Unable to return a number from CASE statement in plsql
Hello all!
Back in November of last year, I received some assistance from user "jarola" regarding changing the color of a column item in a query based on the resulting value. This discussion yielded;
declare
l_query varchar2(4000) := '';
begin
l_query := '
select i.INVENTORY_ID,
io.ORDER_QUANTITY,
CASE
WHEN i.QUANTITY_AVAILABLE=0
THEN ''<span style="color:red;"> ''|| i.QUANTITY_AVAILABLE ||''</span>''
ELSE to_char(i.QUANTITY_AVAILABLE)
END,
i.QUANTITY_AVAILABLE qty_avail_hold,
i.STRAIN_CODE,
i.STRAIN_NAME,
i.GENOTYPE,
i.AGE,
i.***,
(lower(substr(i.ROOM_NUMBER,1,instr(i.ROOM_NUMBER,''-'',1,1)-1))) ROOM_NUMBER
from SM_INVENTORY i,
SM_INVENTORY_ORDER io
where io.ORDER_ID (+)= :F111_MODIFYING_ORDER
and io.INVENTORY_ID (+)= i.INVENTORY_ID';
return l_query;
end;Problem is, sorting (report attributes for column set to "sort") on column i.QUANTITY_AVAILABLE is broken as even though the data in the table is number(12,0), the CASE statement returns it as alpha. I'm having difficulty getting this CASE statement to return a number as these modifications cause generic compilation errors.
ELSE i.QUANTITY_AVAILABLE
ELSE to_number(i.QUANTITY_AVAILABLE)
Google/sqlplus docs have yielded little. Might anyone offer advice?
Thanks!!!
Paul
Hello Varad! Thanks for the reply.
Sorry, but I copied some old information in my code example. the CASE statement I'm actually using is;
CASE
WHEN i.QUANTITY_AVAILABLE=0
THEN ''<span style="color:red;"> ''|| i.QUANTITY_AVAILABLE ||''</span>''
ELSE to_char(i.QUANTITY_AVAILABLE)
END AS QUANTITY_AVAILABLESo I'm already returning the result as labeled "QUANTITY_AVAILABLE".
What I did was click on the pencil/paper icon to the left of the alias of my column in the "Column Attributes" pane in "Report Attributes" to get to the "Column Attributes" page and plugged #QUANTITY_AVAILABLE# into the HTML Expression field of the "Column Formatting" pane of the "Column Attributes" page for the "QUANTITY_AVAILABLE" column.
No joy, sort still broken...
Isn't the problem that fundamentally, the CASE statement returns an alpha? I wouldn't expect the sort to ever work until it can return a number (which it appears SQL, used this way, it cannot do).
So, I considered that END AS QUANTITY_AVAILABLE might be the problem as it's named the same as the column, so I changed it (and the HTML Expression entry) to END AS QUANTITY_AVAIL (changed the name).
Sort as alpha still happening.
Any other thoughts?
Similar Messages
-
Unable to write more than 10 case statements in an object in designer
unable to write more than 10 case statements in an object in designer
XI 3.0 and XI 3.1
Please let me know, any known issues.Hi,
yes this is the limitation you cant write more that 10 case statments but you can reduce the number of time you use the case in your object.
For ex:
If you are writing few conditions on one field then you can add the login in one case only.
case when SAL between 100 and 1000 then 'lowsal'
when SAL between 1000 and 2000 then 'medsal'
when sal between 2000 and 3000 then highsal
else
case when ...then ....
else
end
end
by following the above ex you can solve your problem.
But if you are writing case statement based on dofferent columns then write 10 case statements and remaining conditions you can add at the report level.
using if else condition.
Hope this will help you....
Cheers,
Ravichandra -
Can I activate with a phone number from another state?
Hi, I'm thinking buying the phone but wanted to know if I can or how I can activate it with a number from another state. I travel between Hawaii and Nevada a lot and was thinking about getting a local number in Nevada for the iphone. However, all my billing adresses from credit cards have Hawaii addresses. I also don't have any kind of address in Nevada. Anyone know if this can be done?
reading the OP's statement...
The OP lives in Hawaii and wants to activate a iPhone with a Nevada phone number which the OP does not have yet. The OP also has not billing address in Nevada or any Nevada address. Now while AT&T will give you a out of state number and they will carry a out of state number with you. iTunes is set up to give you a local number, upon activating a new phone iTunes is not designed or equipted to let you choose which areacode you would to start your AT&T account.
*You are correct but not in the case of what the OP is asking for*... The OP does not currently have this number, so once again for the correct advice is below
+iTunes will not allow you to request a number from another state that is different from your billing address, you will have to call AT&T first to setup the account, then activate within iTunes+ -
Set attribute to a Jfield to return type number from Lov
in my lov , i need to return type number and put it in the Jfield . after doin some search , i found the method to set the attribute on that field. PLease and need to send me any URL of doing that method if there is one. (returning type number from LOV)
i have tried this method but it didn't work!!!
Return object from List of values page:
FacesContext fctx = FacesContext.getCurrentInstance();
Application app = fctx.getApplication();
ValueBinding vb = app.createValueBinding("#{bindings}");
DCBindingContainer dc = (DCBindingContainer) vb.getValue(fctx);
DCIteratorBinding dciter = (DCIteratorBinding)dc.get("PrcPartiesLawer1Iterator");
id = (Number)dciter.getCurrentRow().getAttribute("Id");
Name = (String)dciter.getCurrentRow().getAttribute("FullNameN");
setId(id);
setName(Name); AdfFacesContext.getCurrentInstance().returnFromDialog(this,null);
return listener to assign value to Number field:
LawyerReturnOject b = (LawyerReturnOject)returnEvent.getReturnValue();
if(b==null)return;
Number i = b.getId();
getIii().setSubmittedValue(null);
getIii().setValue(i);
String f = b.getName();
getInputText1().setSubmittedValue(null);
getInputText1().setValue(f);
AdfFacesContext af = AdfFacesContext.getCurrentInstance();
af.addPartialTarget(getLawyerLov());
af.addPartialTarget(getInputText1());
and the number type is oracle.jbo.domain.numberHi,
its easier to set the returned value on the ADF binding then on the component directly (at least this is less error prone)
FacesContext fctx = FacesContext.getCurrentInstance();
Application app = fctx.getApplication();
ValueBinding vb = app.createValueBinding("#{bindings}");
DCBindingContainer dc = (DCBindingContainer) vb.getValue(fctx);
FacesCtrlAttrsBinding the_attribute = (FacesCtrlAttrsBinding ) dc.get("nameOfAttributeToUpdate");
the_attribute.set...
Frank -
I have a table with dates which i have converted to a number using the Month Fx. This number is then in a seperate column, which inus e for charts. I am trying to return this number only if the adjacent column contains either "nurse" or "receptionist". ie I dont want them all....
Kang,
Yes. Happy Easter! was cloudy yesterday in Austin, Texas.
I do not know where the formula you posted in your previous post came from. It is certainly not correct. What confuses me about the bottom table is I do not know how it connects to the top table.
Are the groups of people "Clinical Staff", "PDR", "Fire Training" (bottom table column A) groupings of the staff types listed in in the top table, column C?
If so then it may be worth adding some columns to define how the roles map to the training groups.
At this point it must be defined and assumed. Which row are you wanting to fill out for "Nurse" and "Nurse Practitioner"?
A little exaplaination:
the countif() function contains two arguments like this:
=countif(range, test)
the range is a group of cells (often, but not always, a column). The test must be an expression that evaluates to true or false.
so if the column is set to column C of the top table then the range would be expressed as (assuming the table name is "Table 1"):
"Table 1::$G"
to test whether the role is a "Nurse" the test (or condition) would be:
"Nurse"
putting these together you would get a countif() function like this which would return the number of Nurses (not really what you want but getting close):
=countif(Table 1::$G, "Nurse")
you actually want to count when:
A) the month is a particular month and
B) the role is a "Nurse"
you also want to count when:
C) the month is a particular month and
D) the role is a "Secialist Nurse Practitioner"
so you can use the countifs() function.
the countifs() function counts the occurances where only ALL conditions are met.
you would use the counifs() twice and add the results together like this:
=COUNTIFS(test-values1,condition1, test-values2,condition2)
you can add as many test values and conditions as you like (you must add in pairs)
To do this you should add an extra row in the header of the bottom table to hold the month number. Jan is 1, Feb is 2, etc.
Here is what I think you want:
The top table corresponds to the bottom table in your post. notice I added an extra row (to contain the month number):
B3=COUNTIFS(Table 4::$C, "Nurse", Table 4::$G, B$1) + COUNTIFS(Table 4::$C, "Specialist Nurse Practitioner", Table 4::$G, B$1)
this is shorthand for select cell B3, then type (or copy and paste from here) the formula:
=COUNTIFS(Table 4::$C, "Nurse", Table 4::$G, B$1) + COUNTIFS(Table 4::$C, "Specialist Nurse Practitioner", Table 4::$G, B$1)
no select B3 and fill to the right by hovering the cursor over the right edge of the, now select, cell B3 and dragging the little yellow circle to the right. -
Unable to Release request number from DEV
Hi All,
I want to release the request Number from Development,But it is not allowing me and saying :'You are not authorized to lock requests or tasks". please help how can i solve this problem as we Dont have Basis person.
Target System is QAS.
Anu,.
Moderator Message: If you do not have Authorization, then thats that! If you do not have a Basis Consultant, that should not be your headache.
Edited by: kishan P on Mar 2, 2011 11:13 AMse03 ---> search for objects in request/tasks ---> choose correct line (for your report, choose prog) ---> write your report's name ---> choose all request types ( also modifiable)
search your report in other modifiable requests
regards, -
Unable to upload serial number from desktop while doing goods receipt MB01
Hi,
We have upgraded our system from 4.7EE to ECC6.0. While doing goods receipt for purchase order (MB01) in ECC 6 for serial number profile material, I can't find the option for uploading serial number from desktop where as the same option was there in 4.7.
Please help me .....
Thanks
Nrusingha DashHi Experts.,
Thanks for all of you for responding my questions.
I found my question resloved.
Actually, in previous version, the standard program has been modified by taking access key. When the upgradation happened, it got overwrited to the previous one. So, in recent version it is not appearing. -
Unable to create cache groups from CASE-SENSITIVE oracle table's name
Hello All
I have some case-sensitive tables in a oracle database and their columns are the same too. I've tried to cache these tables into TimesTen under a read-only cache group. I think timesten cannot find
case-sensitive tables because as soon as I changed name of the tables, the creation could succeeded. What can I do to overcome this issue? I don't want lose case-sensitive feature. Is it because of
I'm using an old version of TimesTen(11.2.1.4.0)Hi Chris
Thanks for your answer. I'm using SQL Developer(both graphical and by command) to manage Timesten db. When I'm about to select root table for cache group i can see the table and when I
select on it, the caching procedures can not be done and it says your table does not have Primary Key; you can see below that this is not true and the table has two primary key. When I'm
trying to create the cache group via command in work sheet the error is "TT5140: could not find HLR.SUBSCRIBER. may not have privileges"
in Oracle:
CREATE TABLE "HLR"."Subscriber"
"SSI" NUMBER(10,0) NOT NULL ENABLE,
"CCNC" VARCHAR2(50 BYTE) NOT NULL ENABLE,
"Code" VARCHAR2(128 BYTE) DEFAULT NULL NOT NULL ENABLE,
"Account" NVARCHAR2(32),
"Mnemonic" NVARCHAR2(15),
"Region" NVARCHAR2(32),
"UserAddress" NVARCHAR2(32),
"Name" NVARCHAR2(32) NOT NULL ENABLE,
"VPNCode" NUMBER(10,0),
"VPNCCNC" VARCHAR2(50 BYTE),
"SubOrgId" NUMBER(10,0),
"SubscriberTypeId" NUMBER(2,0) DEFAULT 5 NOT NULL ENABLE,
"StatusId" NUMBER(2,0) DEFAULT 1 NOT NULL ENABLE,
"SubscriberClass" NUMBER(2,0),
"DefinedIpAddressId" NUMBER(10,0),
CONSTRAINT "Subscriber_PK" PRIMARY KEY ("SSI", "CCNC") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT) TABLESPACE "USERS" ENABLE,
CONSTRAINT "FK_DefinedIpAdd_Subscriber" FOREIGN KEY ("DefinedIpAddressId") REFERENCES "HLR"."DefinedIPAddress" ("Id") ENABLE,
CONSTRAINT "Fk_Status_Subscriber" FOREIGN KEY ("StatusId") REFERENCES "HLR"."Status" ("Id") ENABLE,
CONSTRAINT "Fk_SubOrg_Subscriber" FOREIGN KEY ("SubOrgId") REFERENCES "HLR"."SubOrganization" ("Id") ENABLE,
CONSTRAINT "Fk_SubscriberType_Subscriber" FOREIGN KEY ("SubscriberTypeId") REFERENCES "HLR"."SubscriberType" ("Id") ENABLE,
CONSTRAINT "Fk_VPN_Subscriber" FOREIGN KEY ("VPNCode", "VPNCCNC") REFERENCES "HLR"."VPN" ("SSI", "CCNC") ENABLE
in TimesTen:
CREATE READONLY CACHE GROUP "PRO1"
AUTOREFRESH MODE INCREMENTAL INTERVAL 5 MINUTES
STATE PAUSED
FROM "HLR"."Subscriber"
"SSI" NUMBER(10,0) NOT NULL ,
"CCNC" VARCHAR2(50 BYTE) NOT NULL ,
"Code" VARCHAR2(128 BYTE) NOT NULL ,
"Account" NVARCHAR2(32),
"Mnemonic" NVARCHAR2(15),
"Region" NVARCHAR2(32),
"UserAddress" NVARCHAR2(32),
"Name" NVARCHAR2(32) NOT NULL ,
"VPNCode" NUMBER(10,0),
"VPNCCNC" VARCHAR2(50 BYTE),
"SubOrgId" NUMBER(10,0),
"SubscriberTypeId" NUMBER(2,0) DEFAULT 5 NOT NULL ,
"StatusId" NUMBER(2,0) DEFAULT 1 NOT NULL ,
"SubscriberClass" NUMBER(2,0),
"DefinedIpAddressId" NUMBER(10,0),
PRIMARY KEY("CCNC","SSI")
) -
Unable to call one number from prepaid phone
>MODERATOR COMMENT: The follow is a post from kentman5. It has been moved from an obscure location to here for better exposure.
Dear Tech Support,
I am unable to dial xxx-xxx-xxxx from my verizon pre paid phone number of xxx-xxx-xxxx. I have used *73 to purge settings. please open up a ticket to correct issue. AT&T is the carrier of the other phone. I own both phones. please contact me at upon resolution.
The automated voice says that is disconnected or no longer in service. I use both phones daily. both are active.
Thank you,
Kent
>Personal info deleted. This is a public, customer to customer/peer to peer forum. Please contact prepaid Customer Service to help resolve your issue<
Verizon Moderator
><Hello,
Your account shows that you made a successful call to Italy today (04/21/14). Is the issue now resolved?
TIME ZONE - US EASTERN. LOCATION - PHILADELPHIA, PA, USA.
I recommend that you always run the latest Skype version: Windows & Mac
If my advice helped to fix your issue please mark it as a solution to help others.
Please note that I generally don't respond to unsolicited Private Messages. Thank you. -
How to eliminate NULL values from case statement?
I have the following query where I am trying to eliminate the NULL record. How can I do this? My query:
select
AttendedSchoolLast3Months = case
when d.scrnval_id = 'AA5639E4-E60C-473F-9B72-354472C11F5B' and d.picklist_value = 'BC349A1E-65A1-4497-A38A-116C83B2028F' then 2 --No
when d.scrnval_id = 'AA5639E4-E60C-473F-9B72-354472C11F5B' and d.picklist_value = 'A529C643-60A7-4D79-AC67-1A8F70791934' then 1 --Yes
end
From [evolv_cs].[dbo].[test_header] [test_header_rv] WITH (NOLOCK)
CROSS APPLY [dbo].[fn_getTestSetupFormDetails](null, [test_header_rv].[test_setup_header_id]) AS [test_header]
CROSS APPLY [dbo].[fn_getTestSetupFormDetails]([test_header].[test_setup_details_id], null) AS [test_details]
JOIN [evolv_reports].[dbo].[test_details_answers_expanded_view] d WITH (NOLOCK) ON
[test_header_rv].[test_header_id] = d.[test_header_id]
AND [test_details].[test_setup_details_id] = d.[test_setup_details_id]
join [user_defined_lut_rv] udl1 with(nolock) on udl1.[user_defined_lut_id] = d.picklist_value
join people_rv p (nolock) on d.people_id = p.people_id
where d.actual_date between '9/1/13' and '9/30/13'
and d.people_id = '7A9ACEE4-ABD5-4905-A54E-659A81048A1A'
And the result currently is:
AttendedSchoolLast3Months
1
NULL
When I ran this query:
select distinct --attendedschoollast3months
d.*
From [evolv_cs].[dbo].[test_header] [test_header_rv] WITH (NOLOCK)
CROSS APPLY [dbo].[fn_getTestSetupFormDetails](null, [test_header_rv].[test_setup_header_id]) AS [test_header]
CROSS APPLY [dbo].[fn_getTestSetupFormDetails]([test_header].[test_setup_details_id], null) AS [test_details]
JOIN [evolv_reports].[dbo].[test_details_answers_expanded_view] d WITH (NOLOCK) ON
[test_header_rv].[test_header_id] = d.[test_header_id]
AND [test_details].[test_setup_details_id] = d.[test_setup_details_id]
join [user_defined_lut_rv] udl1 with(nolock) on udl1.[user_defined_lut_id] = d.picklist_value
--join [education_level] e (nolock) on e.[EducationLevel] = udl1.[description]
join people_rv p (nolock) on d.people_id = p.people_id
where d.actual_date between '9/1/13' and '9/30/13'
and d.people_id = '7A9ACEE4-ABD5-4905-A54E-659A81048A1A'
I get this:
event_log_id people_id group_profile_id actual_date test_header_id test_setup_details_id test_domains_info_id question_caption question_code test_details_answers_id update_log_id test_details_id numeric_value scrnval_id picklist_value remarks narrative test_setup_details_answers_id is_checked date_value details_type_code test_setup_answers_caption test_setup_answers_order test_setup_answers_value output_code answers_category_id answers_category answers_category_code
24E8F88F-9648-4714-9394-D5A3F642C0F0 7A9ACEE4-ABD5-4905-A54E-659A81048A1A NULL 2013-09-26 17:00:00.000 24E8F88F-9648-4714-9394-D5A3F642C0F0 67CDCF44-6308-4E15-8543-3C85DE4C6D4D NULL Attended school in the last 3 months NULL 1BB75044-A65C-4464-ADB9-0CA991019907 7CDD1A4F-41F4-403C-A85E-7FF51B761FF0 3F04BBFF-8DE9-4283-842F-E53A536E3E46 NULL AA5639E4-E60C-473F-9B72-354472C11F5B A529C643-60A7-4D79-AC67-1A8F70791934 NULL NULL 5979600C-B4E6-42DF-BF45-8AFF15ACDD7D 0 NULL PICKLIST Click here for list 1 NULL NULL NULL NULL NULL
24E8F88F-9648-4714-9394-D5A3F642C0F0 7A9ACEE4-ABD5-4905-A54E-659A81048A1A NULL 2013-09-26 17:00:00.000 24E8F88F-9648-4714-9394-D5A3F642C0F0 EBDFBCA5-6E57-4907-9DEF-A1E118F3AB2D NULL Highest grade completed NULL 8F7F4644-4E67-4821-B0FC-A192389F994D 7CDD1A4F-41F4-403C-A85E-7FF51B761FF0 F6C59E67-EC74-4F0C-8EE8-AB372F22255D NULL 4536DD06-871D-4FA7-BA8A-552DB2CA59BC D77F0CAB-505E-4838-AECE-01BAAE8B8EB2 NULL NULL E7C9ECB7-7B40-4115-A6DB-BC752116D68D 0 NULL PICKLIST Click here for list 1 NULL NULL NULL NULL NULL
Ryan DHi,
what I understood from above is that u want to filter NULL records and want to display only not null records. Try below query.
SELECT * FROM(select
AttendedSchoolLast3Months = case
when d.scrnval_id = 'AA5639E4-E60C-473F-9B72-354472C11F5B' and d.picklist_value = 'BC349A1E-65A1-4497-A38A-116C83B2028F' then 2 --No
when d.scrnval_id = 'AA5639E4-E60C-473F-9B72-354472C11F5B' and d.picklist_value = 'A529C643-60A7-4D79-AC67-1A8F70791934' then 1 --Yes
end
From [evolv_cs].[dbo].[test_header] [test_header_rv] WITH (NOLOCK)
CROSS APPLY [dbo].[fn_getTestSetupFormDetails](null, [test_header_rv].[test_setup_header_id]) AS [test_header]
CROSS APPLY [dbo].[fn_getTestSetupFormDetails]([test_header].[test_setup_details_id], null) AS [test_details]
JOIN [evolv_reports].[dbo].[test_details_answers_expanded_view] d WITH (NOLOCK) ON
[test_header_rv].[test_header_id] = d.[test_header_id]
AND [test_details].[test_setup_details_id] = d.[test_setup_details_id]
join [user_defined_lut_rv] udl1 with(nolock) on udl1.[user_defined_lut_id] = d.picklist_value
join people_rv p (nolock) on d.people_id = p.people_id
where d.actual_date between '9/1/13' and '9/30/13'
and d.people_id = '7A9ACEE4-ABD5-4905-A54E-659A81048A1A' ) AWHERE AttendedSchoolLast3Months IS NOT NULLTry this query.
Thanks Shiven:) If Answer is Helpful, Please Vote -
Please Help!!!
Mihi,
Thanks for the details - I've passed these along and will see what further thoughts we have.
Best regards,
Mark
ThinkPads: S30, T43, X60t, X1, W700ds, IdeaPad Y710, IdeaCentre: A300, IdeaPad K1
Mark Hopkins
Program Manager, Lenovo Social Media (Services)
twitter @lenovoforums
English Community Deutsche Community Comunidad en Español Русскоязычное Сообщество -
Help in to convert sql from CASE to DECODE in 11g
11gr2, Windows.
Can somebody help me out in re-writing below sql from CASE statement to DECODE ?
SELECT INVOICE_ID,sum(TOTAL_EXCL_VAT),LEVEL2 as descr,
sum(case when instr(LEVEL2,'Internet')>0 then SUM_QUANTITY else 0 end) as KB --- >> Here
from rator_cdr.INVOICE_DETAIL_LINE
WHERE INVOICE_ID ='000000000000000000' and CALLER='0000000000' and LEVEL1='Gesprekskosten'
group by LEVEL2,INVOICE_ID;ThanksThere is no difference in performance. CASE is a standard syntax that is relatively easy for any developer to read and follow. DECODE is an Oracle-specific function that is much less flexible (you can only use equality conditions, for example) and generally results in more cryptic code.
Justin -
Please help: Case Statement - ORA-01722: invalid number Error
Hi All,
I'm trying to use Case statement to recode Cancelled statuses into two groups
'Reject' if the difference between first date and last date is less than 29 and
'Accept' if the difference between first date and last date is greater than 30
Here is my 'test' data:
STATUS FIRST_DATE LAST_DATE
Transfer 10/08/2011 10/09/2011
Mover 10/08/2011 15/09/2011
Cancel 10/08/2011 16/09/2011
Cancel 10/08/2011 5/09/2011
Here is the syntax
select a.*,
(CASE WHEN a.STATUS ='Cancel' THEN (round(a.LAST_DATE-a.FIRST_DATE))
ELSE 0
END) CAN_DAYS,
(CASE WHEN 'CAN_DAYS' >29 THEN 'Reject'
WHEN 'CAN_DAYS' <30 THEN 'Accept'
END) Reject_Accept
from test a
The first CASE statement works fine and gives me this
STATUS FIRST_DATE LAST_DATE CAN_DAYS
Transfer 10/08/2011 10/09/2011 0
Mover 10/08/2011 15/09/2011 0
Cancel 10/08/2011 16/09/2011 37
Cancel 10/08/2011 5/09/2011 26
but the second CASE produces ORA-01722: invalid number Error. It is something to do with the CAN_DAYS data type, Oracle doesn't see it as Numeric i think.
The result i want to see would be
STATUS FIRST_DATE LAST_DATE CAN_DAYS Reject_Accept
Transfer 10/08/2011 10/09/2011 0
Mover 10/08/2011 15/09/2011 0
Cancel 10/08/2011 16/09/2011 37 Accept
Cancel 10/08/2011 5/09/2011 26 Reject
Could someone please help me to fix the syntax?
Thank you in advance,This seems to give you your desired results...
with test as
( select 'Transfer' as status, to_date('10/08/2011') as first_date, to_date('10/09/2011') as last_date from dual union all
select 'Mover' , to_date('10/08/2011') , to_date('15/09/2011') from dual union all
select 'Cancel' , to_date('10/08/2011') , to_date('16/09/2011') from dual union all
select 'Cancel' , to_date('10/08/2011') , to_date('05/09/2011') from dual
select status
, first_date
, last_date
, CAN_DAYS
, CASE
WHEN CAN_DAYS = 0 THEN NULL
WHEN CAN_DAYS < 30 THEN 'Reject'
WHEN CAN_DAYS >= 30 THEN 'Accept'
END Reject_Accept
from ( select status
, first_date
, last_date
, CASE
WHEN STATUS ='Cancel' THEN round(LAST_DATE-FIRST_DATE)
ELSE 0
END CAN_DAYS
from test
; -
Case Statement Not returning resutlset Varbinary
Declare @val varbinary
set @val = cast('123456789' as varbinary)
select @val as value -- Varbinary Value Result
Declare @check bit
set @check= 1
--THis Case Statement Not returning Result set in Varbinary .
select case @check when 1 then @val else 1 end as valueSee the below part from MSDN documentation reg return type
Returns the highest precedence
type from the set of types in result_expressions and
the optional else_result_expression.
http://msdn.microsoft.com/en-IN/library/ms181765.aspx
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to find the number of fetched lines from select statement
Hi Experts,
Can you tell me how to find the number of fetched lines from select statements..
and one more thing is can you tell me how to check the written select statement or written statement is correct or not????
Thanks in advance
santoshHi,
Look for the system field SY_TABIX. That will contain the number of records which have been put into an internal table through a select statement.
For ex:
data: itab type mara occurs 0 with header line.
Select * from mara into table itab.
Write: Sy-tabix.
This will give you the number of entries that has been selected.
I am not sure what you mean by the second question. If you can let me know what you need then we might have a solution.
Hope this helps,
Sudhi
Message was edited by:
Sudhindra Chandrashekar
Maybe you are looking for
-
Cannot delete item. Keeps on saying item is in use
I am having a problem deleteing a folder that is on my external drive. I drag the folder to the trash and when I try delete it the following message comes up: The operation cannot be completed because the item <folder anme> is in use. I have also tri
-
How can I listen to music on PC bought on Lumia 53...
Hello, I bought today music on my Smartphone on MixRadio. I could download it and everything worked pretty well. Then I had the idea to test it on my PC. When I tried to download the same Music from MixRadio(PC) they tried to charge me again the same
-
Thumbnails not displaying on youtube or facebook.
I made some changes to my computer the other day and now have no idea how to fix what may have potentially caused the thumbnails on youtube and facebook to no longer display. I checked to see if the thumbnails worked in Internet Explorer and Chrome a
-
Periodically, something within Robohelp appears to get corrupt with a project. When that happens, the project compiles without any problems until you click Publish. At that point, a Webhelp dialog displays, saying "Publishing has been cancelled. Acce
-
How do I update Physical Layer
How to I update the table in the physical layer in the OBI admin tool when: 1. the data in the underlying database table changes (meaning the records/rows are added or deleted in the database) 2. the fields in the underlying database table change (me