any case when and the sql clause
Hello:What follows is my sql clause:
SELECT T.*, b.name
OF dbtest1 t
LEFT OUTER JOIN dbtest b ON t.NO = b.empno
WHERE t.ChineseName like '% "| : ChineseName | ' %' AND b.name like "%" | : name | » %'
ORDER BY t.ChineseName
The main problem is that I want to check the b.name if it is null, it can be passed as function NVL, so I try using case when, but it does not work.
When there are the b.name in where clause, the columns of result will not include data without b.name (or implies the b.name is NULL); And that
the result data are not entirely accurate.
is it possible to use the case when it is implemented in the following code snippet:
-case when b.name is not NULL then b.name like "%" | : name | » %'
Else b.name = NULL (b.name = b.name does not seem to work on the analysis of data zero)
end
Thank you very much.
962769 wrote:
The main problem is the table is the form of the cross, and the like clause will filter the
data without a name. Basically, it should show the empty columns, however, it won't.
so, when I test the sql code, I fhound Like "%" | b.Name | ' %' will not get the data when the original dbtest1 table data
has no id corresponding to the BD test. It seems pointless to go the LEFT OUTER JOIN.Thank you
WHERE t.ChineseName like '%'||:ChineseName||'%'
AND (
b.name like '%'||:name||'%'
or b.empno is null
)
Tags: Database
Similar Questions
-
You can move the inserted text to a different location on the picture, if yes how? How can I put the character and the Panel clause up in the photo shop when you type test?
Yes. I find it easier to type text, and then use the move tool (shortcut V) (looks like an arrow) to place it where you want.
To bring up the character and paragraph panels go to WINDOW > CHARACTER or WINDOW > PARAGRAPH.
I hope this helps.
-
Tuning - using the CASE statement in the WHERE clause of the query
Hi all
My request has been changed to use a CASE statement in the WHERE clause to examine the data to some columns based on a parameter value. This modified request is made a full table and constantly running scan. Please suggest what can be done to improve its performance:
Query:
Description of the table:SELECT LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))) AS summary_date, os.acctnum, os.avieworigin_refid, COUNT(1) cnt_articleview, SUM(NVL(autocompletedterm,0)) cnt_autocompletedterm FROM TABLE1 os WHERE os.acctnum IS NOT NULL AND os.avieworigin_refid IS NOT NULL AND os.requestdatetime IS NOT NULL AND UPPER(os.success_ind) = 'S' AND CASE WHEN Param_ValueToCheck = 'FULL' AND get_date_timestamp(os.requestdatetime) BETWEEN TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') THEN 1 WHEN Param_ValueToCheck = 'INCR' AND os.entry_createddate BETWEEN TO_DATE('01-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('31-MAY-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') THEN 1 END = 1 AND CASE WHEN Param_ValueToCheck = 'FULL' AND os.entry_CreatedDate BETWEEN TO_DATE('01-APR-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') AND TO_DATE('07-JUN-2011 00:00:00','DD-MON-YYYY HH24:MI:SS') THEN 1 WHEN Param_ValueToCheck = 'INCR' THEN 1 END = 1 GROUP BY LAST_DAY(TRUNC(TO_TIMESTAMP(os.requestdatetime, 'yyyymmddhh24:mi:ss.ff4'))), os.acctnum,os.avieworigin_refid;
(Number of lines: approx. > amount 600 000 000)
Explain PlanName Null Type ------------------------------ -------- ------------ ARTICLEID NOT NULL NUMBER(20) USERKEY NUMBER(10) AVIEWORIGIN_REFID VARCHAR2(10) SUCCESS_IND VARCHAR2(2) ENTRY_CREATEDDATE DATE CREATED_BY VARCHAR2(10) FILENUMBER NUMBER(10) LINENUMBER NUMBER(10) ACCTNUM VARCHAR2(10) AUTOCOMPLETEDTERM NUMBER(2) REQUESTDATETIME VARCHAR2(19)
Published by: Chaitanya on June 9, 2011 02:44SQL> select * from table(dbms_xplan.display); PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Plan hash value: 2224314832 ---------------------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | ---------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 590 | 33040 | 2501K (1)| 08:20:15 | | | | 1 | HASH GROUP BY | | 590 | 33040 | 2501K (1)| 08:20:15 | | | | 2 | PARTITION RANGE ALL| | 590 | 33040 | 2501K (1)| 08:20:15 | 1 |1048575| |* 3 | TABLE ACCESS FULL | TABLE1 | 590 | 33040 | 2501K (1)| 08:20:15 | 1 |1048575| ---------------------------------------------------------------------------------------------------------- PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 3 - filter(UPPER("OS"."SUCCESS_IND")='S' AND CASE WHEN ('FULL'='FULL' AND "OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-04-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE(' 2011-06-07 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN 'FULL'='INCR' THEN 1 END =1 AND "OS"."REQUESTDATETIME" IS NOT NULL AND CASE WHEN ('FULL'='FULL' AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")>=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "ODS"."GET_DATE_TIMESTAMP"("REQUESTDATETIME")<=TO_DATE(' 2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 WHEN ('FULL'='INCR' AND "OS"."ENTRY_CREATEDDATE">=TO_DATE(' 2011-05-01 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "OS"."ENTRY_CREATEDDATE"<=TO_DATE(' PLAN_TABLE_OUTPUT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 2011-05-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) THEN 1 END =1 AND "OS"."ACCTNUM" IS NOT NULL AND "OS"."AVIEWORIGIN_REFID" IS NOT NULL)
Published by: Chaitanya on June 9, 2011 02:47When it is executed individually, MERGE LOGIC 1 and LOGIC of MERGE 2 take about ten for a daterange of 30 days data.
BUT FULL is to get the scores of APR - JUN, INCR becomes partitions for MAY so not both 30 days.
Are compare us like with like? -
I won't be here but Microsoft seems very happy sending me on the prosecution of the wild goose, and here I landed! I didn't even know that Microsoft had a band, probably not my music a little... In any case, it is the second shortcut of Microsoft which is supposed to take me to the "Windows 7 Compatibility Center. The first, in the Windows help sent me to http://windows.microsoft.com/en-us/windows/support#1TC=windows-7. Not a mention of the word "compatibility" on the page anywhere. Then, enter 'compatibility' in the search for support and here is the result, looks promising. https://www.microsoft.com/en-us/search/result.aspx?q=compatibility. But no, I click on the first result that says Microsoft compatibility Center. Even what seems to be the correct web address, microsoft.com /compatibility and it takes me here http://www.microsoft.com/microsoft-band/en-us/support/hardware/microsoft-band-system-requirements. I give up!
Hi André,.
Please keep us updated.
Unfortunately, the center of compatibility Windows has actually retired. To find out if any program that works with Windows 10 or not, you can check with the developer to program on the compatibility of its operating system. In addition, when you migrate to Windows 10 from a previous version of Windows, you are informed about programs that may not work with Windows 10. However, you can try to install these programs in compatibility mode and check.
Hope this information is useful. Please feel free to answer in the case where you are facing in the future other problems with Windows.
-
WinXP
user belongs to a domain and user does not belong to the local administrator or power users groups, or any custom group and the user is not part of the domain administrators group, but user show that it is adminI did a gpupdate/force and restart twice PC
Yet, user indicate it is always admin when we right click on Start menu and see the possibility to open all usersHi elena_ad,
Your question of Windows is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for the public on the TechNet site. Please post your question in the below link:
http://social.technet.Microsoft.com/forums/en/winserverManagement/threads
-
I can't send or receive any e-mail and the error code: 0x800CCC19 I call the provider and they say it's a software problem. Help, please
1. Windows Mail. But he argued that email account for more than a year without problem.
2 here is the full error message:
"Are subject: how pumpkin pies are made ', account: 'pop3.live.com', server: 'smtp.live.com', Protocol: SMTP, Port: 25, secure (SSL): Yes, error number: 0x800CCC19.
("How pumpkin pies are doing it" the subject of an email I tried to answer to and it does not work)
I get another message when sending email: "your POP2 server has not responded in 60 seconds. You want to wait 60 seconds for the server to respond? »
And I'm waiting for 60 seconds, several times and it does not send
It was 1 year there, not more. Not sure when it started.
Read this article from Microsoft Help Support &:http://support.Microsoft.com/default.aspx/KB/926374
t-4-2
-
In any case to control the speed of the fan to Alienware Aurora R4?
In any case to control the speed of the fan in Alienware Aurora R4?
Hello
You are running the latest version of the Bios?
-
TREE - in any case to enter the prior and his prior ID?
Hi, I have a tree view.
I have branches that may be outside over a trunk.
If I click on a branch, I also want to know what is its parent and its parent company (unless it is already at the top)
If I click on the person that I want to know the Budget, which is the same, but also costs report 13
One trunk
-Report of expenditure 13
-Budget
-The person < = click
Two trunk
-Report of expenditure 24
-Budget
-The person
Then in the SQL, I thought of prior analytical function but I need 2 levels... and we can use that in a SQL tree?Hello
PRIOR can only put back one level.
If the grandparent is unique, you can extract it SYS_CONNECT_BY_PATH results, using REGEXP_SUBSTR.
If this isn't the case, you may need to do a Query of Yo-Yo , you two CONNECT BY queries, in opposite directions.I know that this answer is vague. For a more specific answer, post a small example data (CREATE TABLE and INSERT statements), or expression of the question in terms of scott.emp or hr.employees.
Whatever it is, according to the results you want on the sample data and explain how you get these results from these data. -
case statement and the problem posed by the...
Hello..
Here is the code I use in my pl/sql anonymous block:
I want to do something like this:DECLARE X555 NUMBER; P1_X2 varchar2(10) := to_char(sysdate, 'dd.mm.yyyy'); BEGIN case when P1_X2 = to_char('sunday') then SELECT COUNT(*) into X555 FROM biwh.ORGANIZ Tbl WHERE SAM_FORMA IN ('16') and IDEN_N_TAR in to_date(/*:*/P1_X2, 'dd.mm.yyyy')-3; else SELECT COUNT(*) into X555 FROM biwh.ORGANIZ Tbl WHERE SAM_FORMA IN ('16') and IDEN_N_TAR in to_date(/*:*/P1_X2, 'dd.mm.yyyy')-1; end case; dbms_output.put_line(X555); end;
If it's Sunday, leave this part of the labour code:
can you tell me the correct syntax of the code? where did I did mystake?SELECT COUNT(*) into X555 FROM biwh.ORGANIZ Tbl WHERE SAM_FORMA IN ('16') and IDEN_N_TAR in to_date(/*:*/P1_X2, 'dd.mm.yyyy') -3;
SRY for my English...P1_X2 varchar2(10) := to_char(sysdate, 'dd.mm.yyyy'); BEGIN case when P1_X2 = to_char('sunday')
In the light of the foregoing, you set P1_X2 to a string value that resembles '05.10.2009' and then try to compare it to a string that looks like "Sunday".
I'd be tempted to define P1_X2 as a DATE, then check against that for example
p1_x2 DATE := trunc(SYSDATE); BEGIN CASE TO_CHAR(p1_x2,'fmday') WHEN 'sunday' THEN SELECT COUNT(*) INTO x555 FROM biwh.organiz tbl WHERE sam_forma IN ('16') AND iden_n_tar = p1_x2 - 3; ELSE SELECT COUNT(*) INTO x555 FROM biwh.organiz tbl WHERE sam_forma IN ('16') AND iden_n_tar = p1_x2 - 1; END CASE;
The above assumes that you store iden_n_tar as a 'date at midnight '.
You could go further and have a single query that moves from the "cause" of the where clause:
SELECT COUNT(*) INTO x555 FROM biwh.organiz tbl WHERE sam_forma IN ('16') AND iden_n_tar = p1_x2 - CASE TO_CHAR(p1_x2,'fmday') WHEN 'sunday' THEN 1 ELSE 3 END;
-
Case statement in the SQL Query prompt dashboard
Hi Experts,
I use the following case statement to generate default values in the prompt dashboard based on a condition (the other guest-generated values). Below are two of the query I've tried and the syntax error. I tried all the possibilities (like giving apostrophes, double quotes, don't quote not etc.), but could not understand the question. Don't know what exactly I'm missing here.
Query 1:
SELECT
CASE
WHEN @{PRType} = monthly THEN 'Participant pay '. "" Amount of PayRate "="15000"
WHEN @{PRType} = daily THEN 'Participant pay '. "" Amount of PayRate "="650"
WHEN @{PRType} = hourly THEN 'Participant pay '. "" Amount of PayRate "="1"
ELSE ' 0'
END
OF 'PA-Participant pay. '
Query 2:
SELECT
CASE
WHEN @{PRType} = monthly THEN "15000"
WHEN @{PRType} = daily THEN "650"
@{PRType} = schedule THEN '1'
ELSE ' 0'
END
OF 'PA-Participant pay. '
This is the query that is generated in the log with error message file.
1 log message:
SELECT CASE WHEN Hourly = Monthly THEN "Participant Payroll"."Payrate Amount" = '15000' WHEN Hourly = Daily THEN "Participant Payroll"."Payrate Amount" = '650' WHEN Hourly = Hourly THEN "Participant Payroll"."Payrate Amount" = '1' ELSE '0' END FROM "PA-Participant Payroll"
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 43113] The message returned by OBIS. [nQSError: 27002] Near <>=: Syntax error [nQSError: 26012]. (HY000)
Comment 2:
;CASE WHEN To_Char (Hourly) = 'Hourly' THEN 1 ELSE 0 END
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error occurred. [nQSError: 43113] The message returned by OBIS. [nQSError: 27002] Near <>(): syntax error [nQSError: 26012]. (HY000)
Sorry, I wasn't clear... you must always put this CASE statement in a valid SQL SELECT statement.
SELECT
CASE
When ' @{PRType}' = 'Monthly' THEN '15000'
When ' @{PRType}' = 'Daily' THEN '650'
ELSE '0' END
OF 'PA-Participant pay. '
-
Syntax of UPDATE of Oracle with the JOIN and the WHERE clause
I need to update one of my paintings and can't seem to get the syntax right. I tried 4 different approaches, but does not have a chance. Any help would be greatly appreciated.
Attempt #1: Error: not correctly completed SQL command
UPDATE TESTDTA.F4941
SET TESTDTA.F4941.RSDSTN=TESTDTA.F4981.FHRTDQ,TESTDTA.F4941.RSUMD1=TESTDTA.F4981.FHUOM
FROM TESTDTA.F4941
INNER JOIN TESTDTA.F4981
ON TESTDTA.F4941.RSSHPN = TESTDTA.F4981.FHSHPN
WHERE TESTDTA.F4941.RSSHPN = 647143
AND TESTDTA.F4941.RSDSTN = 0
AND TESTDTA.F4941.RSADDJ > 110365
AND TESTDTA.F4981.FHCGC1 = 'DIS';Try #2: Error report: SQL error: ORA-00904: "TESTDTA." "" F4981 ". "' FHUOM ': invalid identifier 00904. 00000 - '% s: invalid identifier '.
UPDATE (SELECT TESTDTA.F4941
FROM TESTDTA.F4941
INNER JOIN TESTDTA.F4981
ON TESTDTA.F4941.RSSHPN = TESTDTA.F4981.FHSHPN
WHERE TESTDTA.F4941.RSSHPN = 647143
AND TESTDTA.F4941.RSDSTN = 0
AND TESTDTA.F4941.RSADDJ > 110365
AND TESTDTA.F4981.FHCGC1 = 'DIS')
SET TESTDTA.F4941.RSDSTN=TESTDTA.F4981.FHRTDQ,TESTDTA.F4941.RSUMD1=TESTDTA.F4981.FHUOMTry #3: Error report: SQL error: ORA-00904: "TESTDTA." "' F4941 ': invalid identifier 00904. 00000 - '% s: invalid identifier '.
UPDATE (SELECT *
FROM TESTDTA.F4941
INNER JOIN TESTDTA.F4981
ON TESTDTA.F4941.RSSHPN = TESTDTA.F4981.FHSHPN
WHERE TESTDTA.F4941.RSSHPN = 647143
AND TESTDTA.F4941.RSDSTN = 0
AND TESTDTA.F4941.RSADDJ > 110365
AND TESTDTA.F4981.FHCGC1 = 'DIS')
SET TESTDTA.F4941.RSDSTN=TESTDTA.F4981.FHRTDQ,TESTDTA.F4941.RSUMD1=TESTDTA.F4981.FHUOM;Try #4: Error: ORA-00925: Missing keyword 00925. 00000 - "missing IN the keyword"
MERGE TESTDTA.F4941
USING TESTDTA.F4981
ON (TESTDTA.F4941.RSSHPN = TESTDTA.F4981.FHSHPN
AND TESTDTA.F4941.RSSHPN = 647143
AND TESTDTA.F4941.RSDSTN = 0
AND TESTDTA.F4941.RSADDJ > 110365
AND TESTDTA.F4981.FHCGC1 = 'DIS'
)
WHEN MATCHED THEN
UPDATE SET TESTDTA.F4941.RSDSTN=TESTDTA.F4981.FHRTDQ
,TESTDTA.F4941.RSUMD1=TESTDTA.F4981.FHUOM;Finally managed to do work, adding DISTINCT to select. I have pasted the SQL error in Google to begin with. Laughing out loud!
Code snippet work for anyone who comes across this thread...
MERGE INTO TESTDTA. F4941 DST
USING (SELECT DISTINCT TESTDTA. F4941. RSSHPN,
TESTDTA. F4941. RSDSTN,
TESTDTA. F4941. RSUMD1,
TESTDTA. F4941. RSADDJ,
TESTDTA. F4981. FHSHPN,
TESTDTA. F4981. FHRTDQ,
TESTDTA. F4981. FHUOM,
TESTDTA. F4981. FHCGC1
OF TESTDTA. F4941
JOIN INTERNAL TESTDTA. F4981
ON TESTDTA. F4941. RSSHPN = TESTDTA. F4981. FHSHPN
WHERE - TESTDTA. F4941. RSSHPN = 647143 AND
TESTDTA. F4941. RSDSTN = 0
AND TESTDTA. F4941. RSADDJ > 110365
AND TESTDTA. F4981. FHCGC1 = 'SAY') CBC
on (DST. RSSHPN = SRC. FHSHPN)
When matched then update
SET DST. RSDSTN = SRC. FHRTDQ, SUMMER TIME. RSUMD1 = SRC. FHUOM;
Thanks to everyone who helped with this.
-
'Find' is case-sensitive and the option does not appear on the search bar
As I said, it is case sensitive. I looked for an answer and everyone says uncheck case-sensitive on the search bar, but he's not here. I am on a mac with os x 10.9.4 using Firefox 32.0.1.
I thought about it. I had to restart with disabled addons. I don't know which extension caused the problem, but the change stuck when I re-enabled the addons.
-
The elements and the SQL Types
I just started learning apex and I'm confused about the application and page elements. Since they can serve as a kind of variables in the SQL and PL/SQL (for example, by using the syntax variables bind), at some point they should be prescribed a type, since SQL and PL/SQL are two strongly typed languages.
It seems that the items have types, see the documentation (http://docs.oracle.com/cd/E11882_01/appdev.112/e11947/bldapp.htm#BCEDCGGH), but I don't know how they correspond to the SQL types.
For example, I saw that to_date is always used with items of type date picker, implying that it is a string of SQL type.
So the question. What have SQL type apex page/application parts, is what type conversion do I need to use when dealing with items in SQL and PL/SQL?They are all VARCHAR2 (4000) as far as I know - anything application are the same and the page elements is adjustable in number or date more. Put date or number will include only internal validation, check whether the format is match the parameters of globalization of applications.
Denes Kubicek
-------------------------------------------------------------------
http://deneskubicek.blogspot.com/
http://www.Apress.com/9781430235125
http://Apex.Oracle.com/pls/Apex/f?p=31517:1
http://www.Amazon.de/Oracle-Apex-XE-Praxis/DP/3826655494
------------------------------------------------------------------- -
vCenter installed on a virtual machine and the SQL DB on the physical server?
All the
I'll run a VM on vCenter. A question... It is noticed that the best practice not to have the SQL Databsase(Sql 2005) on the virtual computer
but the DB on a physical server with an ODBC connection from the virtual machine. My client will not fail to ask - why, I can't give a clear
answer to the question.
If I can someone state why it is better practice to have the SQL DB on a physical server?
Thank you!!!
Here are a couple
http://www.VMware.com/files/PDF/vc_database_performance.PDF
http://www.VMware.com/files/PDF/SQLServerWorkloads.PDF
I hope that helps a little...
Please consider awarding points by scoring responses like 'proper' or 'helpul.
=========================================================================
-
I have acrobat 9 pro and I see no way to change the spelling of the text. I know the search for instructions to do this it is assumed to be a right pane, but I have no right pane and I don't see how to get one to appear. Thanks for any help.
In Acrobat 9 the tool is called the "Text editor" tool It is included in the "Advanced editing" toolbar, so just with the right button of the toolbar area and select it from the list of available tools. Or you can select: Tools > advanced editing > text editing tool
Maybe you are looking for
-
my ipod is not detected by itunes
Hello, so, as it is said, my ipod is not detected by itunes and it s not because taking usb does not work or has problems because it becomes a hard drive on my computer. I have tried everything but nothing works: I have reset my ipod and itunes, unin
-
photos of photosteam iPhone does not not for mac automatically
I HATE the pictures and would really like to speak or write to the entire team took all the good features of IPhoto and thrown. As the batch changes and events/album fusion. Organize and sort my photos taking much longer and are therefore much more
-
Leave the Section synchronization Batch cleaning
HelloI have a test sequence that uses the synchronization of batch in the following way:1. enter in the Section series Batch2. Enter the batch a Thread single Section3. temperature adjustment4 output batch a wire Section only5 test6 output batch seri
-
X 360 spectrum: spectrum x 360 technical Question
Hello. I plan to buy a new laptop and found that the spectrum series x 360 looks attractive. A decision, however, I would like to know some characteristics of products not appearing only on the specifications page. 1 how many locations does HDD/SSD
-
XP problem constant errors and the loss of the Im... Reformats multiple
Well after a long time to use my computer * the bed... He said that the Config/System file is missing or damaged was told to fix. So after about 10 formats later and the error comes constantly with 1 million other mistakes so many different blue scre