select_list_from_query using the union
As a manual, how to have the APEX_ITEM. SELECT_LIST_FROM_QUERY when the query is likeSELECT 'A' D, 'A' R FROM DUAL UNION ALL
SELECT 'B' D, 'B' R FROM DUAL UNION ALL
SELECT 'C' D, 'C' R FROM DUAL UNION ALL
Please suggestSanjay
Hello
>
select APEX_ITEM.SELECT_LIST_FROM_QUERY(04,NULL,'select 'A' D, 'B' R from DUAL
union all
select 'C' D, 'D' R from dual', 'style=""','','YES',' - Select Details - ', 'f04_' || '#ROWNUM#', NULL, 'NO')LR_COURIER from dual
Bracket missing error appears when you run the above code.
>
To escape the single quotes shipped like this
select APEX_ITEM.SELECT_LIST_FROM_QUERY(04,NULL,'select ''A'' D, ''B'' R from DUAL
union all
select ''C'' D, ''D'' R from dual', 'style=""','','YES',' - Select Details - ', 'f04_' || '#ROWNUM#', NULL, 'NO')LR_COURIER from dual
See you soon,.
PS: Or use the q! Construct
select APEX_ITEM.SELECT_LIST_FROM_QUERY(04,NULL,q'!select 'A' D, 'B' R from DUAL
union all
select 'C' D, 'D' R from dual!', 'style=""','','YES',' - Select Details - ', 'f04_' || '#ROWNUM#', NULL, 'NO')LR_COURIER from dual
Published by: Dominique 21 August 2012 16:19
Tags: Database
Similar Questions
-
A report from a query using the Union
Hello. I try to select an account for this request and then to display the total in a message, but I'm getting one too many returned lines (ORA-01422). Can someone tell me how I can get a total for this request?
Any help would be greatly appreciated.SELECT nvl(count(*),0) INTO conflict_cnt FROM dropper_assign WHERE dropper_id = :dropper_vacations.dropper_id AND trunc(sched_date) between :begin_dt and :end_dt union SELECT nvl(count(*),0) FROM exfc.bundle a, splits b WHERE a.bundle = b.bundle AND b.dropper_id = :dropper_vacations.dropper_id AND trunc(a.actual_dt) between :begin_dt and :end_dt; call_alert.the_error('test: '||to_char(conflict_cnt));
Hello
first: your Union will always return two rows
Second: there is no need to put a nvl() because a county will always return o If nothing with the criteria.select count(1) into v_1 from table1; select count(1) into v_2 from table_2; conflict_cnt = v_1 + v_2; /* that(s it !*/
Jean-Yves
-
selection of a single record using the UNION
Hello. I have two tables different 'address' (home and work). In some cases, a person will have a record in the two arrays 'address', while some people will have only a record in one or the other. I want to return a single record set by b.SID. So if a person has a criminal record in the two tables then I'm just grabbing a name and an address. How can I do this?
Select b.SID, b.address
people a, b House
where b.name = b.SID
UNION
Select b.SID, b.address
people, work b
where b.SID = b.name;something like
select a.name, NVL(b.address, c.address) address from people a, home b, work c where a.name = b.name(+) and a.name= c.name(+)
-
How to eliminate the union clause
I have a requirement where I need to get some recording (say 5 records) of the table and the sum (TOTAL) of some columns in these 5 folders that should be displayed as the last record. Im trying it work with union all clause
Select cd
pid
dt
number
type
sum (iamt) iamt
sum (ALMPs) ALMPs
sum (oamt) oamt
idt
from t1
where code = 'NAQ.
Group by cd, pid, dt, idt
Union of all the
Select 'TOTAL '.
null
null
null
null
sum (iamt) iamt
sum (ALMPs) ALMPs
sum (oamt) oamt
null
from t1
where code = 'NAQ;
is there a way I can avoid using the UNION clause and achieve the same...? Kindly share your thoughts...Hello
Try below:
SELECT cd,
nest,
DT,
NUMBER,
TYPE,
Sum (iAMT) iamt,
Sum (ALMPS) ALMPs,
Sum (OAMT) oamt,
IDT
FROM t1
WHERE code = 'NAQ.
GROUP BY GROUPING SETS ((dt, cd, pid, NUMBER, idt), NULL)Kind regards
Karine -
Alternative to the union in Oracle 10 g
Here's the sql code using the union that I currently use. There are 64 columns of 3 different tables. Out of all the columns that a single column value is a constant for 2 discs.
Select col1, col2, col3,..., 'TO' medium_val
of table1, table2, table3
where table1.col1 = table2.col1
and table2.col1 = table3.col1
and other criteria
Union
Select col1, col2, col3,..., 'GT' medium_val
of table1, table2, table3
where table1.col1 = table2.col1
and table2.col1 = table3.col1
and other criteria
Basically repeating the same code just for the value of a column. Is there any alternative to the union in order to avoid the questioning of two times the same tables.Hello
Here's one way that will work in Oracle 9 (or higher):
WITH all_medium_vals AS ( SELECT 'DE' AS medium_val FROM dual UNION ALL SELECT 'WG' FROM dual ) SELECT col1, col2, col3, .... , m.medium_val FROM table1 , table2 , table3 , all_medium_vals m WHERE table1.col1 = table2.col1 AND table2.col1 = table3.col1 AND ... ;
Do not refer to m.medium_val in the WHERE clause. Leaving him out, you'll do a cross join of your result set of table1, table2, and table3 with 2 lines in all_medium_vals.
Starting Oracle 11, there are also SOME... UNPIVOT.
You will notice that this query is still a UNION, but it's just the UNION of two lines and then by doing the complicated only one query. That will be much more effective that make the complex query twice, and then make a UNION of however many lines that happened to produce. There are ways to generate all_medium_vals without a UNION, but they are not as easy to understand or to debug and are not significantly more effective.
-
How to get the values in a single line, without the help of the union
Hello
I have a table with the structure and the following data
EmpID address phoneno emailid
1001 xyz
1001 1234234
1001 [email protected]
1002 23434
1002 [email protected]
1003 abcd
1003 [email protected]
1004 [email protected]
I need to get a result in this format.
EMP id address phoneno emailid
1001 xyz 1234234 [email protected]
1002 23434 [email protected]
1003 abcd [email protected]
1004 [email protected]
I can do this by using the union, but who gives a performance of questions with a large table. I want to do it using any other way using lead or something, but with the relative to data complexity, I couldn't do it.
Can someone help me please?
Natarajan
Published by: Nikita on December 3, 2009 15:50Select employee_id, max(address), max(phone), max(email) from emp group by employee_id;
Max
-
query: without the help of the union
Hai, everyone,
IHAVE àtable like this:
Table1:
ID emp1 emp2 emp3
1 100 200 300
2 90 295 977
3 150 299 500
and I need the result like this:
100
90
150
200
295
299
300
977
500
the result is just union emp1, emp2 and emp3
That is to say, this type of result, we can produce with this:
Select emp1 in table1 union select emp2 emp3 union table1 select from table1
but I need a query with the same result as above without using the union statement
Thanks in advance...
Published by: jp_valapad on Sep 12, 2008 02:38
Published by: jp_valapad on Sep 12, 2008 02:39But the order guaranteed?
N ° as it is never without an order by ;)
But op didn't say anything about a particular order (again)... -
without the use of union or union of all the
Hello experts
I have the following data below
create the table t_me
(
first_one varchar (1000).
second_one varchar (1000).
third_one varchar (1000).
week_needed varchar (1000)
);
insert into t_me values ('A', 'B', 'C', ' week 1 "');
insert into t_me values ('A', 'B', 'C', ' week 1 "');
insert into t_me values ('B', 'B', 'C', ' week 1 "');
insert into t_me values ('C', 'A', 'C', ' week 2 "");
insert into t_me values ('C', 'A', 'C', "3 week");
insert into values of t_me ('B', 'C', 'B', "3 week");
output desired without the use of union
the characters first_one, second_one, third_one week_needed
Week 1 A: 2 0 0
Week 1 B: 1 3 0
Week 1 C: 0 0 3
Week 2 A: 0 1 0
Week 2 C: 1 0 1
Week 3 A: 0 1 0
Week 3 B: 1 1 0
Week 3 C: 1 0 2
Any help is appreciated. Thank you
Hello
If you want something that works in your version, you should tell what version it is, especially if this version is 12 years old.
Here's a way to make the unpivot operator and rotate in Oracle 9:
WITH cntr AS
(
SELECT LEVEL AS col_num
OF the double
CONNECT BY LEVEL<=>=>
)
unpivoted_data AS
(
SELECT week_needed
col_num
CASE col_num
WHEN 1 THEN first_one
WHEN 2 THEN second_one
WHEN 3 THEN third_one
AS END characters
OF t_me
CROSS JOIN cntr
)
SELECT week_needed, characters
, COUNT (CASE WHEN col_num = 1, 1 END) AS first_one
, COUNT (CASE WHEN col_num = END 2 THEN 1) AS second_one
, COUNT (CASE WHEN col_num = END of the 3 THEN 1) AS third_one
Of unpivoted_data
GROUP BY week_needed, characters
ORDER BY week_needed, characters
;
-
Hello everyone, have a look at the statements below and let me know what wrong with my approach.
CREATE TABLE test (column1 CLOB); INSERT INTO test SELECT to_clob('This is test') FROM dual;
When I run the query below, I get data types incompatible error (ORA-00932). Help, please.
SELECT to_clob('This is test two') FROM dual UNION SELECT column1 FROM test;
Kind regards
Shiva.
Hey Shiva,
Copied from documentation
http://docs.Oracle.com/CD/B19306_01/server.102/b14200/queries004.htm
Restrictions on operators define the set operators are subject to the following restrictions:
- Set operators are not valid on columns of type
BLOB
,CLOB
,BFILE
,VARRAY
, or a nested table. - The
UNION
,INTERSECT
, andMINUS
operators are not valid onLONG
columns. - If the selection list prior the operator set contains an expression, you must provide an alias for the expression column to refer in the
order_by_clause
. - You cannot specify also the
for_update_clause
with the set operators. - You cannot specify the
order_by_clause
in thesubquery
of these operators. - You cannot use these operators in
SELECT
statements containing theTABLE
expressions collection.
- Set operators are not valid on columns of type
-
Columns of Union two problem using the TO_CLOB function
Hello
Let me start by you (a simplified version of) showing the query I'm running:
SELECT
l.Person,
TO_CLOB(l.letter_code ||) "letter has been sent.") Note
letters l
UNION
Select
n.Person
n.Note
n notes
And here's the table structure
LETTERS)
l.Person varchar2 (10);
l.letter_code varchar2 (2);
*)*
NOTES)
n.Person varchar2 (10);
CLOB n.note;
*)*
Each request runs on its own without any problem but when I union together I get a ' * ORA-00932: inconsistent data types: expected - got CLOB * "error. I can't understand what is the cause. The TO_CLOB in the first query is to convert the varchar2 column in a CLOB then why would he be oppose to be clauses with the second query?
Any advice would be much appreciated! Thanks :)You may not use the set operations, UNIONS, MINUS, INTERSECT with CLOB columns etc. simple as that.
-
Confused about how to use ORDER BY in the UNION
I want to dynamically generate the commands in the following order
1. delete the user
2 ALTER DATBASE... .resize command for that user tablespace
3 DROP TABLESPACE for this user
So, I wrote the following sql code
I need output in this order for each diagram like thisSQL > set lines 200 SQL > select 'drop user '||username|| ' cascade;' from dba_users 2 where username in ('S_DMJ','S_MBIN','S_URTL') 3 union 4 select 'alter database datafile '||file_name ||' RESIZE 5M;' FROM DBA_DATA_FILES 5 WHERE TABLESPACE_NAME IN ('S_DMJ','S_MBIN','S_URTL') 6 UNION 7 SELECT 'DROP TABLESPACE '||TABLESPACE_NAME|| ' INCLUDING CONTENTS AND DATAFILES;' 8 FROM DBA_TABLESPACES 9 WHERE TABLESPACE_NAME IN ('S_DMJ','S_MBIN','S_URTL'); 'DROPUSER'||USERNAME||'CASC ---------------------------------------------------------------------------------------------------- DROP TABLESPACE S_URTL INCLUDING CONTENTS AND DATAFILES; DROP TABLESPACE S_DMJ INCLUDING CONTENTS AND DATAFILES; DROP TABLESPACE S_MBIN INCLUDING CONTENTS AND DATAFILES; alter database datafile +DATA/LMPROD/datafile/S_URTL.dbf RESIZE 5M; alter database datafile +DATA/LMPROD/datafile/S_DMJ.dbf RESIZE 5M; alter database datafile +DATA/LMPROD/datafile/S_MBIN.dbf RESIZE 5M; drop user S_URTL cascade; drop user S_DMJ cascade; drop user S_MBIN cascade; 9 rows selected. SQL >
drop user S_URTL cascade; alter database datafile +DATA/LMPROD/datafile/S_URTL.dbf RESIZE 5M; DROP TABLESPACE S_URTL INCLUDING CONTENTS AND DATAFILES;
Hello
Think very carefully about why you need to do this in SQL * more.
Because you need an automated process, PL/SQL would be better?
When you use UNION, you cannot ORDER BY something that is not in the SELECT clause. You can easily assign a sort key in every branch of the UNION and use SQL * more control "COLUMN sort_key NOPRINT" to prevent it to appear in the output, even if it has as a result set.In pure SQL, you can make the UNION in a subquery, then the main query (with the ORDER BY clause) does not need to include the sort key in the output:
WITH union_data AS ( SELECT 'drop user ' || username || ' cascade;' AS sql_txt , username || ' 1' AS sort_key FROM dba_users WHERE username IN ('S_DMJ','S_MBIN','S_URTL') UNION SELECT 'alter database datafile ' || file_name ||' RESIZE 5M;' AS sql_txt , tablespace_name || '2' AS sort_key FROM dba_data_files WHERE tablespace_name IN ('S_DMJ','S_MBIN','S_URTL') UNION SELECT 'DROP TABLESPACE ' || tablespace_name || ' INCLUDING CONTENTS AND DATAFILES;' AS sql_txt , tablespace_name || '2' AS sort_key FROM dba_tablespaces WHERE tablespace_name IN ('S_DMJ','S_MBIN','S_URTL'); ) SELECT sql_txt FROM union_data ORDER BY sort_key ;
Published by: Frank Kulash, June 8, 2011 08:49
-
Is it possible to use the title of column sorting along w / a union?
When I had a simple select statement, I might get the kind work with either one "in order to" in the select statement or with sorting of the column header.
Then, I changed the select a Union. I can get the folders to sort if I specify the column number in the order (for example, the order of 9, 7, 1), but the position column sorts do not work. The records look like they are sorted on page 1, but are not sorted on pages 2-5.
Is it possible to use the title of column sorting and a Union?
Thank you!
LauraLaura:
You can re-write the query in the form
Select col1, col2, col3...
Of
(select col1, col2, col3 from T1
Union
Select col1, col2, col3 from T2
)CITY
-
Hello
I need in which I table based on active groups, that is, each group is to have a separate table.
Now my reports queries all active groups. How to design in the RPD.
* We are unable to build the union of all reports.
Let's take an example
A group table
Group key
Column1
Column2
Group B table
Group key
Column1
Group C table
Group key
Column2
Column1 and column2 here's respective information, but for groups of various assets (is there, we have 3 tables)
The tables of dimensions.
Tried to make paintings like LTS for a single logical table. But the query consists of a single table with two columns
Thanks in advance
Rémy Agarwal
1 table of logic with several (NOT an LTS with several joined tables) LTSS valued content of their respective fragmentation.
Update: and don't forget to put "this source must be combined with other sources at this level" = TRUE
-
Use the value of the sum and compare
I have a table with data below
T1
ID, amount
12,20
13,10
14.5
create table T1 (ID number, amount);
Insert into T1
Select double 12.20;
Union
Select 13,10 double;
Union
Select double 14.5;
I need the sum of the quantity and the value of the sum compares the values as flat > display then 10 0 otherwise amounted
output
ID, amount, derived
12,20,20
13,10,10
14,5,5
If my table has a
T1
12.0
13.5
It should be
T1
12,0,0
13,5,0
You can use the analytic function SUM
select id, amount, case when sum(amount) over() > 10 then amount else 0 end derived from t1
-
the Union and the order of etl_run_num_seq
Hello
Using oracle 11.2.0.3 and have fowlling sql
Select cola, colb
table one
where...
order of teachers
Add a union in this
for example
Select cola, colb
table one
where...
order of teachers
Union
Select cola, colb
of table b
where...
order of teachers
get the message ORA-00933 not correctly completed sql command
Works if do
(select cola, colb)
table one
where...
Union
Select cola, colb
of table b
where...
)
order of teachers
East - the best and only way to do it?
Use the COMMAND BY only once and use the number of the column...
Select cola, colb
table one
where...
Union
Select cola, colb
of table b
where...
order by 1
Maybe you are looking for
-
The update of Firefox 22.0 will disable the protection of my Symamtec?
It is said that it will disable my 13.3.0.9 - 5 Symantec Intrusion Prevention so I shouldn't update, right?
-
Replacing the drive HARD Satellite Pro 4280
I have a SP 4280 and the original hard drive on it does not have earlier. I bought a Hitachi Travelstar 5K 100 40 GB replacement, but I can't seem to make it work. FDisk recognizes the disc as a 40 GB drive and seems to format the drive. However, att
-
Good size of disk RAID 1 for Time Machine
I have a Mac Mini with a Fusion 1 TB drive. What is the recommended size for a backup drive in a RAID 1 using Time Machine configuration?
-
Detect the Signal DC reduction
I have have a signal DC I want to be able to detect if it falls by 'x' amount. How do I would accomplish this? The signal is generally for a period of time and then suddenly falls. I want to detect this decline.
-
Hello How (and when) the EOS M will be able to perform remote shooting, as did the EOS 1100D (and former model)? I used a picture of the range of the EOS with the help of their SDK and c# and the results were amazing. I would like to do the same thin