Help in the CASE statement with amount
Hello ExpertsI amw Group on
Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
With partitioning, OLAP, Data Mining and Real Application Testing options
I'm unable to solve this Case statement.
My requirement is that if the value of the attribute is greater than 50, then add 1 to the sum for attribute 4 the sum should be 4
WITH T AS
(
Select MATH_CONV_SCR 70, 68 MATH_PERC, writ_conv_scr 66, 67 writ_per Union double all the
Select MATH_CONV_SCR 70, MATH_PERC 48, writ_conv_scr 66, 67 writ_per Union double all the
Select MATH_CONV_SCR 70, 68 MATH_PERC, writ_conv_scr 66, 67 double writ_per
)
(
Select)
CASE
WHEN MATH_CONV_SCR > 50 THEN 1
WHEN MATH_PERC > 50 THEN 1
WHEN WRIT_CONV_SCR > 50 THEN 1
WHEN WRIT_PER > 50 THEN 1
TOTAL END)
T
)
The expected answer is
4
3
4
for the respective folders
Please give me the solution
Thank you
RB
Hello
Rb2000rb65 wrote:
Hello ExpertsI amw Group on
Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production...
Thanks for posting the version and sample data; It is very useful.
... Select)
CASE
WHEN MATH_CONV_SCR > 50 THEN 1
WHEN MATH_PERC > 50 THEN 1
WHEN WRIT_CONV_SCR > 50 THEN 1
WHEN WRIT_PER > 50 THEN 1
TOTAL END)
T
Don't forget that the WHEN of a CASE expression clauses are mutually exclusive. If none of them are evaluated to TRUE, then all of the following are not even tried.
)
The expected answer is
4
3
4
for the respective foldersPlease give me the solution
Here's one way:
SELECT CASE WHEN math_conv_scr > 50 THEN 1 ELSE 0 END
+ CASE WHEN math_perc > 50 THEN 1 ELSE 0 END
+ CASE WHEN writ_conv_scr > 50 THEN 1 ELSE 0 END
+ CASE WHEN writ_per > 50 THEN 1 ELSE 0 END AS total
FROM t;
Tags: Database
Similar Questions
-
With the help of the Case clause with clause type
Hello PL SQL gurus
I used a few scripts I found on these forums to create an amortization of mortgage statement. What I'm trying to accomplish is to get the script to run a calculation or use a value in a table based on the value in this table.
Here are two tables:
CREATE TABLE mortgage_facts (customer VARCHAR2 (20), result VARCHAR2 (20),)
quantity NUMBER (10.3));
INSERT INTO mortgage_facts VALUES ('Smith', 'Ready', 131828.81);
INSERT INTO mortgage_facts VALUES ('Smith', 'Annual_Interest', 3,348);
INSERT INTO mortgage_facts VALUES ('Smith', 'Payments', 72);
INSERT INTO mortgage_facts VALUES ('Smith', 'PaymentAmt', 0);
Mortgage of CREATE TABLE (customer VARCHAR2 (20), pmt_num, no.4, principalp NUMBER (10.3), interestp NUMBER (10.3), mort_balance NUMBER (10.3));
INSERT INTO mortgage VALUES ('Smith', 0, 0, 0, 131828.81);
If the value in the mortgage_facts table is zero, I want the script runs a calculation to be used in a MODEL clause. If it is not zero, I would use this value instead of the calculation. Here is the script I am getting an error on (I have bolded the part in question):
SELECT c, p, to_char (round(m,2), 'fm$ 9999999.00') principal_balance,
TO_CHAR (Round(pp,2), 'fm$ 9999999.00') towards_principal,
TO_CHAR (Round(IP,2), 'fm$ 9999999.00') towards_interest,
TO_CHAR (Round(MP,2), 'fm$ 9999999.00') monthly_payment
MORTGAGE COMPANY
MODEL - see 1
IGNORE THE NAV
REFERENCES R ON
* (SOME customers, fact, amt - see 2 *)
FROM mortgage_facts
* MODEL SIZE (customer, done) MEASURES (amount amt) - see 3 *.
REGULATION SEQUENCE
*(*
CASE WHEN mortgage_facts.fact = 'PaymentAmt' AND mortage_facts.amt = 0 THEN
*(*
* amt [ALL, 'PaymentAmt'] = mortgage_facts.amt*
*)*
ON THE OTHER
*(*
* amt [everything, "PaymentAmt"] = (amt [CV (), "Ready"] *)
* Power (1 + (amt [CV (), 'Annual_Interest'] / 100/12), *)
(* AMT [CV (), 'Payments']) *.
(* AMT [CV (), 'Annual_Interest'] / 100/12)) / *.
* (Power (1 + (AMT [CV (), 'Annual_Interest'] / 100/12), *))
(* AMT [CV (), 'Payments'])-1) *.
*)*
END
*)*
*)*
SIZE OF (customer cust, made) measures (amt)
Amortization of PRINCIPAL
PARTITION BY (customer c)
DIMENSION (p) 0)
MEASURES (pp, interestp ip principalp, mort_balance m, mc, mp 0 customer)
REGULATION SEQUENCE
ITERATE (1000) UP TO (ITERATION_NUMBER + 1 =
r.AMT [MC [0], 'Payments'])
(ip [ITERATION_NUMBER + 1] = m [CV () - 1] *)
r.AMT [MC [0], 'Annual_Interest'] / 1200,.
MP [ITERATION_NUMBER + 1] = r.amt [mc [0], "PaymentAmt"],
pp [ITERATION_NUMBER + 1] = r.amt [mc [0], 'PaymentAmt']-ip [CV ()].
m [ITERATION_NUMBER + 1] = m [CV () - 1] - pp [CV ()]
)
ORDER BY c, p
Any help is very appreciated. Thank you!!OK, here we go, go with the iterative model:
select * from mortgage_facts model partition by (Customer) dimension by (1 p) measures(loan, payments, INTEREST, PAYMENTAMT, INTERESTPMT, PRINCIPALPMT, balance) rules iterate(1e9) until (iteration_number+2 >= payments[1]) (loan[iteration_number+2]=loan[1] ,payments[iteration_number+2]=cv(p)-1 ,interest[iteration_number+2]=interest[1] ,paymentamt[iteration_number+2]=ROUND( (LOAN[1] * (INTEREST[1]/12/100)*Power((1+INTEREST[1]/12/100), PAYMENTS[1])/(Power((1+INTEREST[1]/12/100),PAYMENTS[1])-1)), 2) ,INTERESTPMT[iteration_number+2]=round(balance[cv(p)-1]*interest[1]/1200, 2) ,PRINCIPALPMT[iteration_number+2]=paymentamt[cv()]-INTERESTPMT[cv()] ,balance[iteration_number+2]=balance[cv()-1]-PRINCIPALPMT[cv()] ) CUSTOMER P LOAN PAYMENTS INTEREST PAYMENTAMT INTERESTPMT PRINCIPALPMT BALANCE Smith 1 131828.81 72 3.348 0 0 0 131828.81 Smith 2 131828.81 1 3.348 2023.55 367.8 1655.75 130173.06 Smith 3 131828.81 2 3.348 2023.55 363.18 1660.37 128512.69 Smith 4 131828.81 3 3.348 2023.55 358.55 1665 126847.69 Smith 5 131828.81 4 3.348 2023.55 353.91 1669.64 125178.05 Smith 6 131828.81 5 3.348 2023.55 349.25 1674.3 123503.75 Smith 7 131828.81 6 3.348 2023.55 344.58 1678.97 121824.78 Smith 8 131828.81 7 3.348 2023.55 339.89 1683.66 120141.12 Smith 9 131828.81 8 3.348 2023.55 335.19 1688.36 118452.76 Smith 10 131828.81 9 3.348 2023.55 330.48 1693.07 116759.69 Smith 11 131828.81 10 3.348 2023.55 325.76 1697.79 115061.9 Smith 12 131828.81 11 3.348 2023.55 321.02 1702.53 113359.37 Smith 13 131828.81 12 3.348 2023.55 316.27 1707.28 111652.09 Smith 14 131828.81 13 3.348 2023.55 311.51 1712.04 109940.05 ....
-
Hello I want to put a condition in CASE the statement translated which excludes zerios.
SELECT
CASE WHEN substr(a.gbobj,1,1) < 4
THEN (a.GBAPYC + a.GBAN01 + a.GBAN02 + a.GBAN03 + a.GBAN04 + a.GBAN05 +)
a.GBAN06+a.GBAN07)/100 ELSE a.GBAN07/100 END FINALNUMBERS
OF MMSDM. SRC_E1_MMS_F0902 one
WHERE
A.GBCTRY <>0 AND A.GBLT = 'AA' and a.gbfy = "11"
My results are
FINALNUMBERS
0
122323.34
45456
How don't exclude zero record in my results? I tried to not equal to "0" FINALNUMBERS in which the clause, but it did not work.
Thank you
Published by: user610131 on October 27, 2011 13:49
Published by: user610131 on October 27, 2011 13:50user610131 wrote:
Thank you guys. This has been useful.I understand what Solomon did, but I'm confused when I need to run the full query. How to do this?
I do a query online when I have to pull additional fields.
You need a subquery to reference the alias finalnumbers.
Do everything except the test for finalnumbers (and cklause ORDER, of course) in the subquery. view online, such as used Salomon or a WITH clause that:WITH got_finalnumbers AS ( SELECT 'AA' Ledger, CASE WHEN a.GBCO='00001' THEN 'C86001' ELSE 'C' || Trim(a.GBCO) END Company, 'G000' Region, CASE WHEN length(TRIM(a.GBMCU))=7 AND substr(TRIM(a.GBMCU),6,2)='00' AND substr(TRIM(a.GBMCU),1,1)<>'4' THEN 'GS'|| TRIM(a.GBMCU) ELSE 'G'|| TRIM(a.GBMCU) END departments, 'E' || a.gbobj Accounts, CASE WHEN d.SUB_CLASS IS NULL THEN 'NA' ELSE d.code END market, a.gbfy Cal_year, sum(CASE WHEN substr(a.gbobj,1,1)<4 THEN (a.GBAPYC+a.GBAN01+a.GBAN02+a.GBAN03+a.GBAN04+a.GBAN05+ a.GBAN06+a.GBAN07)/100 ELSE a.GBAN07/100 END) FINALNUMBERS FROM MMSDM.SRC_E1_MMS_F0902 A LEFT OUTER JOIN MMSDM.SRC_E1_MMS_F0901 B ON (A.GBCO = B.GMCO) AND (A.GBAID = B.GMAID) LEFT OUTER JOIN mmsdm.src_e1_mms_f0006 c ON a.gbmcu=c.mcmcu LEFT OUTER JOIN getcb30.MMS_GL_SUB_CLASS d ON trim(c.MCRP11)=d.SUB_CLASS WHERE A.GBCTRY<>0 AND A.GBLT='AA' and a.gbfy = '11' GROUP BY a.gbco, trim(a.gbmcu), a.gbobj, a.gbfy, d.SUB_CLASS, d.code ) SELECT * FROM got_finalnumbers WHERE finalnumbers != 0 ORDER BY GBOBJ;
-
Need help in the CASE statement
Hello
My query gives the result like this
ONC BO DT countkey
RF036 I HAVE 1 156
RF036 I HAVE 8 445
RF036 O 3 1320
RF036 O D 2547
I need output like
ONC DM CC MC BC
156 445 1320 2547 RF036
Thank you
LonyBased on your data...
WITH D AS ( SELECT 'RF036' AS CNO, 'I' AS BO, '1' AS DT, 156 AS COUNTKEY FROM DUAL UNION ALL SELECT 'RF036' , 'I' , '8' , 445 FROM DUAL UNION ALL SELECT 'RF036' , 'O' , '3' , 1320 FROM DUAL UNION ALL SELECT 'RF036' , 'O' , 'D' , 2547 FROM DUAL ) SELECT CNO, MAX(DM) AS DM, MAX(CC) AS CC, MAX(MC) AS MC, MAX(BC) AS BC FROM ( SELECT CNO, CASE WHEN BO = 'I' AND DT = '1' THEN COUNTKEY ELSE NULL END DM, CASE WHEN BO = 'I' AND DT = '8' THEN COUNTKEY ELSE NULL END CC, CASE WHEN BO = 'O' AND DT = '3' THEN COUNTKEY ELSE NULL END MC, CASE WHEN BO = 'O' AND DT = 'D' THEN COUNTKEY ELSE NULL END BC FROM D ) GROUP BY CNO
-
Help: How to use the Case statement in the ODI11g Interface?
Hello
My basic source I get 'Year' values and I want that these values result code in the interface and after translation want to push on the target system.
Example:
Database source, I get value for
Year
2010
2011
2012
When I get the year 2010 I want to change the value in "FY10".
When I get year 2011 I want to change the value in "FY11.
and even for the year 2012 to "FY12.
I've tried to make the Case statement, but had no success.
I don't want to create the lookup table in the source system.
Any help in this matter.
Thank you
Concerning
Sher
Published by: Sher Ullah Baig on August 26, 2012 17:52CASE
WHEN source_column = '2010' THEN 'FY10.
WHEN source_column = '2011' and THEN 'FY11.
WHEN source_column = '2012' and THEN 'FY12.
END -
Syntax of the case statement / WHEN
The table I use a depreciation per fiscal year and the fiscal period. I try to have the amount of depreciation to go to 2 different columns based on the fiscal year and the fiscal year. I'm doing it with a nested case statement. I know that is not correct, because I get the message ORA-00905. I'm relatively new to sql and it is contribtuing to my problem as well. Here is the code I have and suggestions / corrections would be appreciated. Thanks for the help...
SELECT
lao PDR. DEPTID as DEPTID,
lao PDR. ASSET_ID as ASSET_NO,
PA. Descr as DESCRIPTION,
lao PDR. ACCOUNT_AD as AD_ACCT,
PDL. DE_ACCT, to take into ACCOUNT
lao PDR. ADEATH as AMT_DEPR,
PDL. JOURNAL_ID as JRNL_ID,
PDL. JOURNAL_DATE as JRNL_DT,
lao PDR. FISCAL_YEAR as FY,
lao PDR. ACCOUNTING_PERIOD AP,
CASE
WHEN RDP. FISCAL_YEAR = 2014 THEN
WHEN RDP. PERIOD ACCOUNTANT = 11 THEN pdr. DEPR
END AS CURR_MONTH,
CASE
WHEN RDP. FISCAL_YEAR <>2014
WHEN RDP. ACCOUNTING PERIOD <>11 THEN pdr. DEPR
END AS PRIOR_MONTH
OF PS_DEPR_RPT pdr
INNER JOIN PS_DIST_LN pdl
THE pdl. BOOK = pdr. BOOK
AND pdl. BUSINESS_UNIT = pdr. BUSINESS_UNIT
AND pdl. FISCAL_YEAR = pdr. FISCAL_YEAR
AND pdl. ACCOUNTING_PERIOD = pdr. ACCOUNTING_PERIOD
AND pdl. ASSET_ID = pdr. ASSET_ID
AND pdl. CF_SEQNO = pdr. CF_SEQNO
INNER JOIN PS_ASSET PA
WE pa. ASSET_ID = pdl. ASSET_ID
AND pa. BUSINESS_UNIT = pdl. BUSINESS_UNIT
WHERE
lao PDR. BUSINESS_UNIT = "A0465.
AND pdr. BOOK = 'RUN '.
AND ((pdr. FISCAL_YEAR = 2014 AND pdr. ACCOUNTING_PERIOD = 11) OR (pdr. FISCAL_YEAR = 2014 AND pdr. ACCOUNTING_PERIOD = 10))
Hello
2713822 wrote:
Thank you... I appreciate the information you provide when you answer these questions. I always try to get the amount (from the same column) for 2 rows in different columns. I tried the LAST_VALUE and LAG but it took a long time for the queries to run, I'm looking for another way to do the same. I'm only using SQL to retrieve data. I don't have the ability to create or insert.
I looked the information above and the CASE statement to look like this:
CASE
WHEN RDP. FISCAL_YEAR = 2014
AND pdr. ACCOUNTING_PERIOD = 11
THEN the RDP. ADEATH AS CURR_MONTH
ON THE OTHER
lao PDR. ADEATH AS MONTHS PREVIOUS
END
But I'm now getting an "ORA-00905: lack of keyword" message.
What I'm trying to do is to draw 2 lines 1 to 2014 / 11 and another for 2014 / 10. The amount for the period 2014 / 11 should go in the current column and the amount for the period 2014 / 10 should go in the previous column.
Before current assets management
01 AB01 50.01 50.03
....
If you want to give an alias for a column, then you can say "AS nome_alias" after that tell you what that is in this column.
'AS nome_alias' applies to the entire column. Cannot use 'alias_name' in the middle of an expression, for example, in the middle of a CASE expression, before the END keyword.
If you want to have 2 separate output columns, curr_month and prior_month to your output, you must then 2 separate columns in your SELECT clause. for example:
SELECT pdr.branch
pdr.asset
CASE
WHEN pdr.fiscal_year = 2014
AND pdr.accounting_period = 11
THEN pdr.depr
END AS curr_month
CASE
WHEN...
THEN...
END AS prior_month
PDR
;
If post you some sample data (CREATE TABLE and INSERT statements), the results and explanations, I could show you how to complete the... sections.
To find out what version of Oracle you have, use
SELECT *.
SINCE the release of v$.
The output can be messy, like this:
BANNER
-------------------------------------------------------------------
CON_ID
----------
12 c Oracle database Release 12.1.0.1.0 - 64 bit Production
0
PL/SQL Release 12.1.0.1.0 - Production
0
CORE Production 12.1.0.1.0
0
AMT for 64-bit Windows: Version 12.1.0.1.0 - Production
0
NLSRTL Version 12.1.0.1.0 - Production
0
The important thing is the number 5 parts on the first line; 12.1.0.1.0 in the example above.
-
Excel and the CASE statement.
Hello Experts,
I use a CASE statement on the column of CHAR type as follows:
CASE WHEN Sales.Ret = 'Y' THEN 'Return' END of OTHER 'new '.
It gives an error: Odbc driver returned an error (SQLExecDirectW).
Whereas, when I use another CASE statement with column Numrical it works perfectly.
CASE WHEN Sales.Amount < END If NOT 100 40 THEN 40
Am I missing an Excel data source definition related to the CHAR data type?
My source is MS Excel 2003 and OBIEE 10.1.3.4.1
Thank you for any comments, help.
~ Ash
PS: the details of the error are the following:*.
Error codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 16001] ODBC error state: 37000 code:-3100 message: error [Microsoft] [ODBC Excel Driver] syntax (missing operator) in query expression ' case when T46. [Retirement] = "Y" then "known" other "new" end "... [nQSError: 16014] Prepare the SQL statement failed. (HY000)
Publ. SQL: SELECT Sales.Tran_date, saw_0, CASE WHEN Sales.Ret = 'Y' THEN 'Return' ELSE 'New' END saw_1, network. "" Network name "saw_2, Sales.Amount saw_3 FROM P4UD ORDER BY saw_0, saw_1, saw_2Sorry, the button is 'Ask DBMS' (biee 10g)
-
call the statement box inside the case statement
I am writing a program which requires me to run a statement box inside another case statement. Although this sounds like a simple thing, I need to be able to call the case statement using a sequence structure, where s1 sends the true value to the case, s2, a fake. Then I need to record the results of this instruction box in a text file. Attatched is a simplified version of what I'm trying to do. Please note that the way my program runs may not call the case statement without using a sequence structure, two nesting box instructions is not feasible. I hope someone out there can help me because I was stuck trying to find this for awhile.
Thank you
LVStudent wrote:
[...] I can't call the case statement without using a sequence structure
Yes you can. You just need to be smart.
LVStudent wrote:
I don't think I can use a state machine to fix this.
I think you probably can.
With respect to your original post. What are these s1 and s2 are you talking about? My opinion on the matter, it is that you want to select a case based on the values of several controls Boolean. If this is correct, I do this:
Build your Boolean controls in a table, convert the table number and insert it into the structure of your business. No button pressed = 0, s1 = only 1, s2 = only 2 both = 3. This works for Boolean values as much as you want and is an easy way to make a decision that depends on many entries.
-
Case statement with a select &; date in
Hello everyone,
This is my first discussion, so please bare with me.
I am trying to write a case statement with a select statement that compares the dates.
When I write an instruction box with a select statement in it compares everything but dates it works fine. Once the date is there, he collapses.
Here is a super simple example of what I'm trying to do, "b.in_serv_dt" is a date
Select unit_no,
case when ((sélectionnez b.in_serv_dt de b unit_dept_comp_main où a.unit_id = b.unit_id et b.in_serv_dt) > = 1 January 2012 "") then "everybody wins."
When ((sélectionnez b.in_serv_dt dans l'unit_dept_comp_main b où a.unit_id = b.unit_id et b.in_serv_dt) < = 1 January 2012 "") then "Nobody wins".
end
of ottawa_unitmain_v one
Any help would be greatly appreciated
Thank you very much
Hello
your statement of formatting:
Select unit_no
case when ((select b.in_serv_dt
of unit_dept_comp_main b
where a.unit_id = b.unit_id
and b.in_serv_dt
") > = JANUARY 1, 2012"
) and then "everybody wins."
When ((select b.in_serv_dt
of unit_dept_comp_main b
where a.unit_id = b.unit_id
and b.in_serv_dt
)<=>=>
) and then "no winner".
end
of ottawa_unitmain_v oneI see "partial conditions": <... and="" b.in_serv_dt="">> that have no meaning.
I guess it's a kind of "typo" and I ignore them.
If the statement is:
Select unit_no
case when ((select b.in_serv_dt
of unit_dept_comp_main b
where a.unit_id = b.unit_id
") > = JANUARY 1, 2012"
) and then "everybody wins."
When ((select b.in_serv_dt
of unit_dept_comp_main b
where a.unit_id = b.unit_id
)<=>=>
) and then "no winner".
end
of ottawa_unitmain_v oneI guess that the "b select" retrieve one line, through the design of database (forced...)
As already written: be careful with data types: avoid "implicit conversions" (when you compare different data types, Oracle has convert the data type of the other side, a side example: "mystring = mynumber" is transformed into 'TO_NUMBER (mystring) = mynumber', or 'mydate = mystring' translates mydate = TO_DATE (mystring,
) ")
Even better: use explicit conversions, use explicit formats when necessary.
Best: use no conversion on columns from the constants, but use the correct data type for the constant.With this in mind:
Select unit_no
case when ((select b.in_serv_dt
of unit_dept_comp_main b
where a.unit_id = b.unit_id
) > DATE = ' 2012-01-01'
) and then "everybody wins."
When ((select b.in_serv_dt
of unit_dept_comp_main b
where a.unit_id = b.unit_id
)<= date="">=>
) and then "no winner".
end
of ottawa_unitmain_v one
But note that b.in_serv_dt EQUAL to 1 January 2012 (at 00:00:00) is OK for both WHEN the conditions; then the a "win."Now: the subselect statement is identical in the 2 options of the case... You could work differently: (I add the "ELSE" in case one line as NULL in_serv_dt;) I guess that an INNER JOIN is OK, maybe you need a LEFT OUTER JOIN (if some lines of A have no corresponding row in B)
SELECT a.unit_no
, CASE WHEN b.in_serv_dt > = DATE '' 2012-01-01
THEN "everyone wins"
WHEN b.in_serv_dt< date="">
While "Nobody wins".
ELSE ' who knows... ". »
END who_wins
Of ottawa_unitmain_v one
INNER JOIN unit_dept_comp_main b
ON a.unit_id = b.unit_id
;Best regards
Bruno Vroman
-
Case statement with building xml
Select
() XMLType.GetClobVal
XMLElement ("variable"
XMLAttributes (vcInternationalDate?" as "type")
XMLAgg (XMLElement ("item",
CASE WHEN THE TEMPO IS NOT NULL THEN
, XMLElement ("utc", TO_CHAR (TIME,' dd/MM/YYYY HH24:MI:SS)) END))
, XMLElement ("timezone_offSet", ZONE SCHEDULE)
)
)
)
)
like 'CREATIONDATE '.
of twgenericosdb. TEST
WHERE ID = 1
The query above without the case statement producing the result to follow:
< type variable = "vcInternationalDate [:]" >
< item >
< utc > 2009-12-20 15:00 < / utc >
< timezone_offSet > 3600000 < / timezone_offSet >
< / point >
< / variable >
I'm looking for is a way in the case where the time utc is null statement do not tag the utc, utc is NULL the query returns the following result
< type variable = "vcInternationalDate [:]" >
< item >
< utc > < / utc >
< timezone_offSet > 3600000 < / timezone_offSet >
< / point >
< / variable >
I'm trying to use the instruction box to return utc of the tag in the case of the UTC is NULL, but I get the error ORA-00917: Missing comma.
Can someone help me?
Thank you very much.Try
SELECT XMLTYPE.GetClobVal (XMLELEMENT ("variable", XMLAttributes('vcInternationalDate[]' AS "type"), XMLAGG(XMLELEMENT("item", CASE WHEN TEMPO IS NOT NULL THEN XMLELEMENT("utc", TO_CHAR(TIME, 'dd/MM/yyyy HH24:MI:SS')) END), XMLELEMENT("timezone_offSet", TIMEZONE)))) AS "CREATIONDATE" FROM twgenericosdb.TEST WHERE ID = 1
You can replace the CASE with NVL2
SELECT XMLTYPE.GetClobVal (XMLELEMENT("variable", XMLAttributes('vcInternationalDate[]' AS "type"), XMLAGG(XMLELEMENT("item", NVL2(TEMPO, XMLELEMENT("utc", TO_CHAR(TIME, 'dd/MM/yyyy HH24:MI:SS')), NULL), XMLELEMENT("timezone_offSet", TIMEZONE))))) AS "CREATIONDATE" FROM twgenericosdb.TEST WHERE ID = 1
URS
Edited by: metzguar the 06.05.2010 15:04
-
TDE is not "transparent" to the CASE statement
Hello
I have installed oracle (10) database with TDE. It works very well with almost all queries. But I have problems when I try to use the CASE statement.
He comes to the table, I created:
{color: #0000ff} create table t_test)
col1 varchar (128)); {color}
This query returns an empty result (as planned, because there is still no data in the table).
{color: #0000ff} to select)
When col1 = 'test' then 'test '.
end) as Carter
of t_test
{color}
I now encrypt the column with the following statement:
{color: #0000ff} change alter table t_test (col1 encrypt using "AES256" without salt); {color}
And try again the same statement:
{color: #0000ff} to select)
When col1 = 'test' then 'test '.
end) as Carter
of t_test
{color}
He now returns {color: #ff0000} ORA-00932 inconsistent data types: expected BINARY got {color} CHAR
But if I try:
{color: #0000ff} select *.
of t_test
{color}
There is no errors (returns empty result, as expected).
I tried even with data, with the same result.
Could someone please tell me what I'm doing wrong here?
Thank you.You touch the Bug 6262107 'ORA-932 of the CASE expression sought with encrypted column:
Description:
"ORA-932 incompatible data types: expected BINARY got TANK ' is triggered.
on a query with a case expression sought on a column with TDE.for example:
CREATE TABLE TDE_TEST (COL1 VARCHAR2 (1));
INSERT INTO TDE_TEST VALUES('1');
ALTER TABLE TDE_TEST CHANGE (COL1 ENCRYPT WITHOUT SALT);
SELECT CASE WHEN COL1 = '1', THEN 'A' OF ANOTHER END 'B' OF TDE_TEST;
^
ORA-00932: inconsistent data types: expected BINARY got TANKWorkaround solution:
Convert a simple case of the searched case expression expression.So, I updated the sql works:
SQL > select (case col1
2 when 'test' then 'test '.
3 end) as Carter
4 * of t_test
/
no selected lineI hope this helps.
-
As there is no support for Windows XP SP2 updates (I managed to get the Microsoft SP3) if I go back to my computer to the original state with recovery Dell how do I get Service Pack 2 and 3 again. Deleted files gives access to the trash... they no longer heard by KIJIJI when I tried to place an ad that some well known hacker has been using my IP address. This means that he can see literally everything I do on my computer. Really need help
overthehillandonaroll
Run Windows Update after recovering the system. It will offer you all the updates, including service packs. Run repeatedly until it shows that no more updates to date are available. Boulder computer Maven
Most Microsoft Valuable Professional -
Hi all.
I use a case statement to represent the values for different regions in a command prompt. I'm having some difficulties, with the values in the case statement. Here is an example of a simplified and shortened my code version.
CASE
WHEN 'Region '. "" Region name "="A"THEN"AMERICA ".
WHEN 'Region '. "" Region name "= 'B' THEN 'CHINA '.
WHEN 'Region '. "" Region name "= 'C' THEN 'EUROPE '.
WHEN 'Region '. "' Name of the region ' = 'A' AND 'B' AND 'C' THEN 'GLOBAL '.
END
My error when I use it in my statement. The formula is accepted, however, all the values are displayed in my guest except 'GLOBAL '.
How can I be able to assign a "GLOBAL"value in my guest? ".
Jagadekara I think that you do not get the point. Any given row retrieved from a data source cannot have all three at one point values!
AJ was trying to tell you, is that your CASE logic has no sense at all.
-
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.
-
I got confused on this CASE
(1) SELECT BOX WHEN 111 = "111" THEN 'YES' ELSE ' ' END OF THE DOUBLE - YES
(2) SELECT CASE WHEN COALESCE (111 111) DOESN'T = "111" THEN 'YES' ELSE ' ' END OF THE DOUBLE - YES
(3) SELECT CASE WHEN COALESCE (111, '111') = '111' THEN 'YES' IS ' ' END OF THE DOUBLE
ORA-00932: inconsistent data types: expected NUMBER obtained TANK
What exactly the things happening between 2 & 3. ' nt it implicitly convert as case 2 is because that in case 3, the first value is anyway not null as CAS2... This leads to confusion.
I have read the Oracle documentation and there is an implicit data type conversion table. It also indicates that can be converted. There is always some confusion raised. Anyone could wrap this confusion?
No, the function coalesce requires that all entries to be of the same data type because they are arguments of this function.
Conversion of implicit data type occurs generally when things are compared with operators (as you do in examples 1 and 2.
There is not many functions/procedures of this nature that the mixed data types and convert them for you.
So, it is nothing to do with the CASE statements, it's in with him COALESCE function. It is overloaded for particular data types, but it requires all arguments to be of the same data type.
Maybe you are looking for
-
Satellite PRO C50-A-1E0 - failure of Windows 10 - now Toshiba Video Player is missing
Hi all I've updated for Windows 10 drivers recommended by "Toshiba Service Station", all were successful outside of Toshiba Video Player. He said now "our product is not available for update!Any ideas? I can't download it anywhere, and the fact that
-
What in fact supply Erazer X 315 use type?
Given that the game is going to be freezing when the CPU usage goes up to 90%, I am I think that maybe the power isn't quite enough to Erazer X 315. Can anyone tell me what type of use Erazer X 315 power and how much watts put the output is.
-
1 error in writing on a text - installer with Application Builder file
I wrote an installer using the Application Builder to install the runtime engine that allows any computer without LabVIEW to run an .exe program. Setup runs and installs engine race and then as a .exe VI. When it is done installing, the .exe VI opens
-
original title: virus my computer always tells me that I have like 23 viruses and deleted programs infected and he always does. and he tells me that I have to buy a program. and it does not allow me on the internet through regular channels. you are a