Handeling string in a select statement
Hi friends,I would like to know how I can handle strings in a SQL select statement?
SQL > SELECT 'string' from dual
Her send me errors when the string is "or &." For example, as if string = Mike & Karen project
You can also tell me wht other characters, such as ', & can make a question?
Thank you.
citing alternative:
http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14251/adfns_sqltypes.htm#sthref377
Tags: Database
Similar Questions
-
Insert a variable + string using the select statement with cfquery
I'm doing an insertion by a select statement where the insert for one of the fields should be a combination of a vaule comes from the selection and concatenated with a string of text. Is this possible and if what the correct syntax so? Here is an example of what I'm trying, but does not.
< name cfquery = "createnote" datasource = "#application.datasource #" >
INSERT INTO gtbl_notes (notedate, strCustomerID, notetype, note, notecreatedby)
SELECT "#currentdate #", strCustomerID, "miscellaneous", "#gtbl_people.email # DELETED because of HARD BOUNCE ', 'Bounce Routine.
OF gtbl_people, gtbl_bounces
WHERE gtbl_bounces.email = gtbl_people.email AND gtbl_bounces.subscriber = 1 AND gtbl_bounces.status = 2< / cfquery >
Any input would be greatly appreciated.
Concatonation is possible with most, if not all of the databases. The syntax is a specific software and you do not your specify.
-
How to split string separated by commas and pass to the clause of the select statement
Referring to article How to divide string separated by commas, then pass to clause of a select statement, tquery that there the following plan:
Query1:
select * from emp where ename in ( select regexp_substr('SMITH,ALLEN,WARD,JONES','[^,]+', 1, level) from dual connect by regexp_substr('SMITH,ALLEN,WARD,JONES', '[^,]+', 1, level) is not null );
Base1:
Plan hash value: 4242290184 -------------------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | 133 | 7 (29)| 00:00:01 | |* 1 | HASH JOIN | | 1 | 133 | 7 (29)| 00:00:01 | | 2 | VIEW | VW_NSO_1 | 1 | 46 | 3 (34)| 00:00:01 | | 3 | HASH UNIQUE | | 1 | | 3 (34)| 00:00:01 | |* 4 | CONNECT BY WITHOUT FILTERING| | | | | | | 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 | | 6 | TABLE ACCESS FULL | EMP | 14 | 1218 | 3 (0)| 00:00:01 | -------------------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - access("ENAME"="$nso_col_1") 4 - filter( REGEXP_SUBSTR ('SMITH,ALLEN,WARD,JONES','[^,]+',1,LEVEL) IS NOT NULL)
However, the following query generates the plan I want:
Query2:
select * from emp where ename in ('SMITH','ALLEN','WARD','JONES');
Plan2:
Plan hash value: 3956160932 -------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 4 | 348 | 3 (0)| 00:00:01 | |* 1 | TABLE ACCESS FULL| EMP | 4 | 348 | 3 (0)| 00:00:01 | -------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter("ENAME"='ALLEN' OR "ENAME"='JONES' OR "ENAME"='SMITH' OR "ENAME"='WARD')
Can I change the query1 query for plan2?
As Juliet was mentioned in the first SQL that you generate from the ENAME list that you must pass in the IN clause when executing. But in the second SQL, it passed as a static value. So first SQL must do more work. So you see a different execution plan.
But this is a work around to get what you are looking for. But I can't say it's a foolproof method. But anyway here you go.
SQL > var ename_list varchar2 (100)
SQL > exec: ename_list: = 'SMITH, ALLEN, WARD, JONES ';PL/SQL procedure successfully completed.
SQL > select *.
2 of PEM
where the 3 «,» | : ename_list | ',' like '%', | Ename | ',%';EMPNO, ENAME, JOB HIREDATE DEPTNO ID COM SAL MGR
---------- ------ --------- ---------- --------- ---------- ---------- ---------- ----------
7369 SMITH COMMITTED 7902 2975 2 APRIL 81 0 20
7499 ALLEN 7698 1600 20 FEBRUARY SALESMAN 81 300 30
7521 WARD 7698 1250 22 FEBRUARY SALESMAN 81 500 30
7566 JONES MANAGER 7839 2975 2 APRIL 81 0 20SQL > select * from table (dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------------------------
SQL_ID, 848zhvbvgf7d6, number of children 0
-------------------------------------
Select * from emp where «,» | : ename_list | ',' like '%', | Ename
|| ',%'Hash value of plan: 2872589290
--------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 2 (100) | |
|* 1 | TABLE ACCESS FULL | EMP | 1. 38. 2 (0) | 00:00:01 |
--------------------------------------------------------------------------Information of predicates (identified by the operation identity card):
---------------------------------------------------1 - filter(','||:ENAME_LIST||',' LIKE '%,'||") ENAME "|", %')
19 selected lines.
SQL >
-
SQL SELECT statement as a parameter in the procedure of string
Hi all
I'm new to PL/SQL and I must get a procedure as parameter select SQL select statement as a VARCHAR and the production output the result of the statement with a few changes. Can someone help me solve this problem?
A possibility I thought at was to use a REF CURSOR. The following example works but binds me to a specific table (in the example of the "customers" table). However, I need the ability to specify arbitrary tables in the select statement parameter.
My idea was to modify this example to work in the following code, but it does not work (I get a compile error):SET SERVEROUTPUT ON DECLARE TYPE my_cur IS REF CURSOR; query_cursor my_cur; BEGIN OPEN query_cursor FOR 'SELECT * FROM customers'; DECLARE record_type customers%ROWTYPE; BEGIN LOOP FETCH query_cursor INTO record_type; EXIT WHEN query_cursor%NOTFOUND; DBMS_OUTPUT.PUT_LINE('some output ... '); END LOOP; END; CLOSE query_cursor; END; /
Does anyone has an idea how can I solve my problem?SET SERVEROUTPUT ON DECLARE TYPE my_cur IS REF CURSOR; query_cursor my_cur; BEGIN OPEN query_cursor FOR 'SELECT * FROM customers'; DECLARE record_type query_cursor%ROWTYPE; BEGIN LOOP FETCH query_cursor INTO record_type; EXIT WHEN query_cursor%NOTFOUND; DBMS_OUTPUT.PUT_LINE('some output ... '); END LOOP; END; CLOSE query_cursor; END; /
Thank you very much!
(I'm using Oracle 11 g)This can help.
Re: Dynamic Extraction on dynamic Sql -
Skip and capture the Oracle SQL record dirty in a select statement
Hello
I have the Oracle Oracle 11.2.0.4 database when I run a select query.
Question:
10 columns have given Date format. When I try to execute this query into a FROG he says, a month not valid. Since the records are billion in nature, I am not able to know which line has this problem.
Is there a way I can capture the failed row and add it to other tables and continues with the select statement regardless of this error
OK, you have several TO_DATE functions fed a string that is built on the fly. At least part of the time, the chain that is built does not match the date format mask used.
For example:
TO_DATE (SUBSTR (TO_CHAR (SQ_W_PURCH_CYCLNS_ORA. LAST_SUBMITTED_ON_DTTM_WID), 0, 8). » -'|| SUBSTR (TO_CHAR (SQ_W_PURCH_CYCLNS_ORA. (LAST_SUBMITTED_ON_DTTM_WID), 9, 6), "YYYYMMDD-HH24MISS")
"SQ_W_PURCH_CYCLNS_ORA. LAST_SUBMITTED_ON_DTTM_WID' does not have a string where characters 5-6 are in the range 01-12. You'll have to do an analysis on this column. From its data and how that is managed by to_char. What ARE the data type of ' SQ_W_PURCH_CYCLNS_ORA. LAST_SUBMITTED_ON_DTTM_WID' and what is a typical value?
As others have said, this is simply an impossibility for a column of a table to actually have invalid month (or day, or year, or hour or minute or second). ONLY, you get this error during the conversion of a string to a date with the TO_DATE function.
-
Hello community, I have a problem when creating a function. The purpose of this function is to check the table of weather gave yesterday or not. We must check this on different tables on different sachems. We are creating a function with input variables.
CREATE OR REPLACE FUNCTION IN_SCHEMA.IS_YDAYDATA_TO_TABLE
(
in_schema IN VARCHAR2,
in_tablename IN VARCHAR2,
in_datefield IN VARCHAR2,
)
RETURNS INTEGER
AS
-Declaring variables
v_is_true INTEGER.
BEGIN
SELECT
CASE
WHEN MAX (in_datefield) = TRUNC(SYSDATE-1)
THEN 1
ON THE OTHER
0
END
IN
v_is_true
Of
in_schema.in_tablename
;
RETURN v_is_true;
END;
/
When creating, I got error: [error] ORA-00942 (44:19): PL/SQL: ORA-00942: table or view does not exist
How to use the values of the input variables on the table select statement names?
Hello
Here's a way you can use dynamic SQL statements for this task:
CREATE OR REPLACE FUNCTION IS_YDAYDATA_TO_TABLE
(
in_schema IN VARCHAR2,
in_tablename IN VARCHAR2,
in_datefield IN VARCHAR2,
in_first_date DATE DEFAULT SYSDATE - 1,.
in_last_date DATE by DEFAULT NULL
)
RETURNS INTEGER
AS
-IS_YDAYDATA_TO_TABLE returns 1 if in_schema.in_tablename.in_datefield
-contains all the dates in the in_first_date of the range through included in_last_date
- and it returns 0 if there is no such lines.
-If in_last_date is omitted, the search only the data on in_first_date.
-If in_first_date is omitted, it defaults to yesterday.
-Time parts of the in_first_date and in_last_date are ignored.
-Declaring variables
sql_txt VARCHAR2 (1000);
v_is_true INTEGER.
BEGIN
sql_txt: = 'SELECT COUNT (*).
|| 'FROM ' | in_schema | '.' || in_tablename
|| 'WHERE ' | in_datefield | ' > =: d1'
|| «AND» | in_datefield | '< > >
|| 'AND ROWNUM = 1';
dbms_output.put_line (sql_txt |) '= sql_txt in IS_YDAYDATA_TO_TABLE"); -For debugging
Sql_txt EXECUTE IMMEDIATE
IN v_is_true
With the HELP of TRUNC (in_first_date) - d1
TRUNC (NVL (in_last_date
in_first_date
)
) + 1 -- d2
;
RETURN v_is_true;
END is_ydaydata_to_table;
/
DISPLAY ERRORS
If you must use dynamic SQL statements, put all the SQL statement in a single string variable, such as sql_txt in the example above. In this way, you can easily see exactly what will be executed. Comment out the call to dbms_output under test is completed.
Try to write functions that will address not only the question that you have now, but similar questions that you may have in the future. For example, now that interest you only to the verification of the data of yesterday, but later, you might want to check another day or range of days. The above function combines the convenience of a function simple (looks like yesterday data if you don't tell him otherwise) with the power of a more complex function (you can use the same function to check any day or range of days).
-
normalize the schema of the table in a select statement (without view)
Hello
I have a table storing a physical value, mean temperature for different locations every minute. The table schema is as following: timestamp (datetime), rental (string), value (number).
Do you know a way to have a select statement, return of lines with the following data: timestamp, the value at location1, value of place.2 guests, etc.
This will help me to create time series in he same diagram in my reporting tool.
This may be possible with a view, but I don't have access to the database, the best I can do is set my a data source such as a select statement.
Thank you!
Brahim
PS. We use Oracle 10 g R2
Hello
8e07ad81-CDAE-4c23-b0fb-b6cd117cf5bc wrote:
Hello
I have a table storing a physical value, mean temperature for different locations every minute. The table schema is as following: timestamp (datetime), rental (string), value (number).
Do you know a way to have a select statement, return of lines with the following data: timestamp, the value at location1, value of place.2 guests, etc.
This will help me to create time series in he same diagram in my reporting tool.
This may be possible with a view, but I don't have access to the database, the best I can do is set my a data source such as a select statement.
Thank you!
Brahim
PS. We use Oracle 10 g R2
What you're asking about is called pivoting. The ahs Forum FAQ page devoted to this topic: Re: 4. How can I convert rows to columns?
Since you're using Oracle 10, you cannot use the SELECT... Function PIVOT; You can use GROUP BY and CASE instead.
Do ' t worry not about creating views. What you can do with views, you can also do it using a WITH clause in your query.
If you get stuck, please post some sample data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also to publish the results you want from this data, as well as your best attempt to query a specific question.
Explain, using specific examples, how you get the results desired from data provided.
See the FAQ forum: Re: 2. How can I ask a question on the forums?
-
JDBC PreparedStatement gives null after the execution of a valid SELECT statement
Hello
I have the following code:
As you can see, this function executes a select statement. Before I continue, let me first say that executing the exact same statement in PL/SQL Developer (external program) gives correct/expected results. In addition, run this on my Windows gives correct results environment. I seem to have this problem only on my Unix (SunOS) environment.public static String GetJobLogLocation(Connection connection, int jobId) throws SQLException { String sqlstr = "SELECT LOGFILE_NAME FROM apps.fnd_concurrent_requests WHERE REQUEST_ID = ?"; PreparedStatement prest = connection.prepareStatement(sqlstr); prest.setInt(1, jobId); ResultSet rs1 = prest.executeQuery(); String rv = null; if (rs1.next()) { rv = rs1.getString(1); System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + rv); } rs1.close(); prest.close(); return rv; }
in any case, I get out of this function (running against my Unix environment, of course):
+ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > + null
The thing is, it doesn't error out, which means that the result set contains a string, but the string is returned to me with the null value, even if there is a real valid result (that is, in this case, a path).
Someone has an idea, what happens? I tried to use ojdbc6.jar AND ojdbc14.jar is, with the same results. I just don't understand...
Thank you.
Published by: 964530 on 4 January 2013 14:31
Published by: EJP on 01/07/2013-17:48: added {noformat}{noformat} tags and removed your bizarre bold formatting. Please do this properly in future.
ASCI says:
I'm glad that this is a not prove to be a stupid question. At least I'm feeling a little justified due to this fact.There is no stupid question...; (o)
So what remains is: your selection is too early. Can join after insertion, update to each line to trigger the table that loggs insert/update timestamp and the contents of the LOGFIILE_NAME field?
Good bye
DPT -
Return multiple values from a function in a SELECT statement
I hope I've provided enough information here. If not, let me know what I'm missing.
I create a view that will combine the information from several tables. Most are pretty simple, but there are a couple of columns in the view that I need to get by running a function within a package. Even if this is quite simple (I have a function named action_date in a package called rp, for example, that I can use to return the date that I need through SOME rp.action_date (sequence_number).
Here is the question: I really need to return several bits of information of the same record (not only action_date, but also action_office, action_value, etc.)-a join of the tables will work not here, as I will explain below. I can, of course, perform a function separate for each statement, but this is obviously inefficient. Within the select statement of the view, however, I don't know how each of the values that I need to get back.
For example, right now, I have:
Table 1:
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 just simply join Table1 and Table2 because I have to perform processing in order to determine the rows returned matching, I really need to select. If the package opens a cursor and treats each line until it finds the one I need.
The following works but is ineffective since all calls to the package returns the columns of the same record. I don't know how to put all the values that I need in 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 in my SELECT statement or I'm going about this all wrong?
Any suggestions?
Thank you very much!Hello
What you want is a Query of Top - N , what you can do using the ROW_NUMBER analytic function in a subquery, 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 returns a single line (at most).
I suspect you'll actually get a rank for each group , where a group is defined by a value in a table in which you join.
In this case, add a PARTITION BY clause to the ROW_NUMBER function.
If post you a small example of data (CREATE TABLE and INSERT statements), I could show you exactly how.
As I don't have your tables, I'll show you the use of the tables in the scott schema.
This is a view containing data in the scott.dept table and also to scott.emp, but only for the highest employee in each Department (in other words, the employee whose oldest hire date). If there be a tie for the first hire date, while the candidate with the lowest empno is selected.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
Moreover, one of the conditions to the query you posted has been
action_office LIKE 'E'
which equals
action_office = 'E'
(AS is always equivalent to = if the string that follows AS does not contain the winning cards.)
Did you mean say that or did you mean something like this:action_office LIKE 'E%'
Instead?
-
Try to make a loop on a select statement in a procedure
Ok
I'm writing a procedure that will make an operation on every table in a select statement.
Example: I want to add a column in each table that starts with "XX_" (XX_01, XX_BD, etc.)
I have new procedures.
I guess I have to use a cursor that is defined as:
Then what?cursor xbtable is select * from user_tables where table_name like 'XX_%'; begin open xbtables; loop
How to make this work.
Also, I have to use substr() on xbtable to extract parts of the name of the table...
Can anyone help?
THXI'm sorry, I made a mistake
cursor xbtable is select * from user_tables where table_name like 'XX_ % ';
String VARCHAR2 (200);
Start
for everything in the loop of xbtable
string: = 'ALTER TABLE ' | Everything.table_name | "ADD column_name column-definition."immediately run a string;
end loop;
end;
-
Hello
I'm doing a loop on a select statement, I give as input to select a string with a list of numbers, separated by "," (I call it projectIdList)
but in the loop it iterates only on the first element
for example, if I give a string 1,2,3,4,5
just 1 iteration happen
Here's the head
I'm in (select substr (the_string, decode (level, 1, 1, instr(the_string,',',1,level-1) + 1), decode (instr(the_string,',',1,level), 0, length (the_string), instr(the_string,',',1,level) - decode (level, 1, 0, instr(the_string,',',1,level-1))-1)) (select projectIdList from double the_string) ProjectID connect by level < length (replace (translate (the_string,'01234567890 ', ' 00000000000') '0')) + 2) loop
does anyone have an ideal?
Concerning
SallemelI don't have a version 9i database to test on (as he has not supported), but I think it works on 9i if you wrap the link by select in another selection...
SQL> ed Wrote file afiedt.buf 1 declare 2 v_projectlist varchar2(100) := '2,8,5,4'; -- This is my "parameter" 3 cursor cur_v is 4 select projectID 5 from ( 6 select substr(the_string, decode(level, 1, 1, instr(the_string,',',1,level-1)+1), 7 decode( instr(the_string,',',1,level), 0, length(the_string), instr(the_string,',',1,level) 8 - decode( level, 1, 0, instr(the_string,',',1,level-1))-1) ) ProjectID 9 from (select v_projectlist the_string from dual ) 10 connect by level < length(replace(translate(the_string,'01234567890','00000000000'),'0')) + 2 11 ); 12 begin 13 for i in cur_v 14 loop 15 dbms_output.put_line('Row: '||cur_v%ROWCOUNT||' - Value: '||i.ProjectID); 16 end loop; 17* end; SQL> / Row: 1 - Value: 2 Row: 2 - Value: 8 Row: 3 - Value: 5 Row: 4 - Value: 4 PL/SQL procedure successfully completed. SQL>
Just give it a go.
-
Can I use a hexadecimal string with a case statement?
Simple question:
Can I enter a hexadecimal string to a case statement and have the case statement see it as hex?
I understand that I could convert the hexadecimal string to a number and then enter the hexadecimal number to the case statement but I am curious to know if I could have the case see the string itself as hex without this added feature.
Would be nice to not have to convert all my numbers throughout my code strings
Thank you
-Eric
How long are the strings? Since you mention convert in numbers, they are probably short and all of same length.
Are there different possible channels how?
Case header includes \-codes in the case of a label deal selector As string, so that should be enough for your use. For example this code turns the LED (.. .so that a simple string of "\00\00" of wiring would not be!)
(See also the last sentence of the "enumerated values" section of the help).
-
Hey everybody,
First of all, Yes, I searched through the 8.5 database schema guide. As I went through the scheme, I've developed some ideas on how to collect the data you want. However, if someone has already developed or found the SQL statements (which I'm sure that someone already has) it would help by reducing to the minimum of the buggs in my data collection program.
All these statistics must be grouped by CSQ and selected for a certain time interval (
and ). That is, levels of 1 hour. I have no problem to get a list of results and then perform v.f. to achieve the desired final result. Also, if I need to run several select statements for tables of essentially two join, please include two statements. Finally, I saw the RtCSQsSummary table, but I need to collect data for the past, not at this time. 1 total calls presented by the CSQ
2. total number of calls answered by the CSQ
3 total number of calls abandoned by the CSQ
4. percentage of calls abandoned by CSQ (if it is not stored in the database, I think:
/ ) 5. average abandon time in seconds (if it is not stored in the DB, I think: sum (
) / ) 6. service level - % calls answered in 90 seonds by a set of skills (I have seen metServiceLevel in the ContactQueueDetail table; however, I need to find how to configure this threshold for application)
7. average speed of response by CSQ
8 average conversation by CSQ calls
9. the aggregates connected full-time resources or agents CSQ
10. resources/agents of CSQ ready time
I realize that some of them should be easy to find (as I always am search in the guide of db schema), but I was reading how a new record is created for each step of the call so I could easily see how I could get inaccurate information without properly developed select statements.
Any help will be greatly appreciated.
Brendan
Brendan,
I read your message very well.
You have the schema of database with tables and description. each table has its associated tables (connected with primary and foreign keys). I think you should start the tables to determine what you need.
Cisco uses the stored procedure to prepare the reports. the stored procedure is 'sp_csq_interval' to create the report.
Activity report of Queue Service contact"
HTH
Anas
Please note all useful posts
-
uniol all in the select statement
Hi I have a situation where I have to return the value based on the if statement, is it possible to put union all in the select statement
My use case is
IN the column State
If column01 > 0 to condtion 't'
IF column02 > 0 that the condition of 'Y '.
Condition IF COLUMN03 > 0 THAN 'w '.
If COLUMN04 > 0 that the condition of "Z".
Select 't'
TableName
where column01 > 0
Union of all the
Select "y".
TableName
where column02 > 0
Union of all the
Select 'W '.
TABLENAME
WHERE COLUMN03 > 0
I have what it takes to show value as it
EmpName, condition, empno
Jerry, T, 0158754585
TOM, Y, 0054789568
Am in oracle database 11 g 2
Yes you can put all THE UNION here
Select empname, 't' State, empno from tablename where column01 > 0
Union of all the
Select empname, 't' State, empno from tablename where column02 > 0
Union of all the
Select empname, condition of "W", empno FROM tablename WHERE COLUMN03 > 0
Union of all the
Select empname, condition of "Z", empno FROM tablename WHERE COLUMN04 > 0
and if you are looking for how to remove duplicates because your line might have satisfied all the conditions and my happen 4 times in your result set, you just need to give them an order and filter it.
For example, you want this
If column01 > 0 to condtion 't'
ELSE IF column02 > 0 that the condition of 'Y '.
Another condition of THAN > 0 IF COLUMN03 'w '.
otherwise if COLUMN04 > 0 that the condition of "Z".
Select empname, condition, empno, in
(
Select a.*, row_number() over (partition by empno arrested by myorder) rn
Of
(
Select empname, 't' State, empno, 1 myorder tablename where column01 > 0
Union of all the
Select empname, 't' State, empno, 2 myorder tablename where column02 > 0
Union of all the
Select empname, condition of "W", empno 3 myorder FROM tablename WHERE COLUMN03 > 0
Union of all the
Select empname, empno, condition of 'Z', 4 myorder FROM tablename WHERE COLUMN04 > 0
) a
) where rn = 1
-
Dear all,
We hope that all are doing well.
I need your help once again, my requirement is to write a trigger for "select statement" on a particular table, the name and the date of the user who executed.
your help will be appreciated.
Thanks in advance.
OS: RHEL 6.1
DB: 11.2.0.3
Trigger is not possible on the SELECT statement, you can audit only by database.
Or can save your select queries to application level.
Maybe you are looking for
-
Dysfunction of Qosmio F10 Windows MCE TV Tuner
Hey everybody I use a Qosmio F10. Now for a few good years, anyway he came the age old time do a restore cd revovery just to speed him up again and the dealer him a new lease of life. Everything worked fine after the relocation outside the TV in Medi
-
Portege R500 and Windows 7 drivers
Some drivers W7 happened 03.09.2009 for R500 - but unfortunally the 3G a dWlan are not included. Work does'nt Insallaing Vista drivers (even in Vista mode). Can someone help me? RgdsLars
-
Epson SX205 stopped printing inkjet printer
I have an Epson SX205 printer. Tonight, it just stopped printing. There is commuicates with the office, insofar as it analyzes without difficulty, but when I try to print something, it remains silent. I tried to uninstall and reinstall nothing doesn'
-
reload the OS V5-123-3466 pre-sales question
Hello - I've been owner of a DELL laptop forever now and is considering moving to acer, but we're not off to a good start. On the v5-123-3466, I hope to be able to pass on the HARD for one SSD drive that seems very easy to do (unlike Asus)-however I
-
Unable to print business cards P1102w of Word 2007 / Windows 7
New computer under Windows 7 and Office 2007, free Wi - Fi to P1102w. I had trouble printing envelopes, but set the print properties > source = Auto Select and can now print envelopes ok. I tried the same thing when I try to print business cards, pri