How to filter records in a UNION ALL query
Hi all
I have only one requirement to filter records in a query UNION all. If we do not all matching records to one of the union, all question them.
create table test_1(n1 number,n2 number,n3 number) insert into test_1 values(1,2,3); insert into test_1 values(11,22,33); insert into test_1 values(55,66,77); Case-1 : SELECT N1,N2,N3 FROM TEST_1 WHERE N2=2 UNION ALL SELECT N1,N2,N3 FROM TEST_1 WHERE N3=3 Output is : This is desired output(so we are good) 1,2,3 1,2,3 Case 2 : SELECT N1,N2,N3 FROM TEST_1 WHERE N2=22 UNION ALL SELECT N1,N2,N3 FROM TEST_1 WHERE N3=44 Output : (Here is the problem: If we don't have matching records for anyone union all query we don't want any records) Output is coming : 11,22,33 Out put : No Records (We want this output.)
I hope I have given the clear example of my requirement.
Thank you.
with
test_1 as
(select 1 n1, n2 2, n3 3 of all the double union)
Select 11,22,33 from all the double union
Select double 55,66,77
)
Select the n1, n2, n3
from (select n1, n2, n3
of test_1
where n2 =: n2
Union of all the
Select the n1, n2, n3
of test_1
where = n3: n3
)
where exists (select null from test_1 where n2 =: n2)
and it exists (select null from test_1 where = n3: n3)
Concerning
Etbin
Tags: Database
Similar Questions
-
How to filter records in a main query of RDF based on the values of the calculated fields
Hello
I'm working on a report of RDF, where I have my main request which has four fields.
(1) the unique id for the field
(2) numerical value 1
(3) numeric value 2
(4) numeric value 3
I added a CF_Total of calculated field.
The main query returns all the records, but I want to only show that these fields for which the CF_Total has a particular value.
Can anyone help me about how to proceed.
Concerning
Hawker
Hello Hawker,
This is an example, how you can filter based on the formula column. I don't know exactly where you would use. And other related issues.
Give the idea and example how you can start.
Thank you
Hamid
-
entry of the file type, how to filter only .csv
use firefox 21.0
use < input type = "file" accept = "xxx" / >How to filter only .csv (* not include all the files) when scour dialogue
I try to use
.CSV (view all)
text/csv (.csv and show all files)
application/csv (view all)
text /-comma - separated values (view all)
Help me, please
Thank you
Jean-PierreIt looks that there is work still to be done:
- bug 826176 - support of file extension to < entry < = "" accept = "..." "li =" ">
Please, do not comment in the bug reports: https://bugzilla.mozilla.org/page.cgi?id=etiquette.html
-
UNION ALL destroyed performance
Strangely, we have 2 queries, which, when they run independently, running fast enough (2 seconds on the one hand, instantaneous to the other), but when they are concatenated into a UNION ALL query without the ORDER BY clause, it takes 45 seconds for him to run.
We tried to push the SQL code in a WITH clause and some other rewrites of the subquery, but no performance boost. Anyone seen this before?
version 10.1.0.4
-= Chuckjust a thought... I didn't really study plans explain it... (I find these very difficult to read, you do not have these SQL * Plus, you did?)
Tom Kyte mentioned somewhere (I find the thread later) you can use ROWNUM in two UNION ALL queries to "refine" the query. You might want to try it.
Because of the ROWNUM materialize you each request separately before combining the results. -
How to filter the records that contains the Spanish character?
Hello
I had an obligation to always records based on the Spanish character.
Kindly guide me for below.
To filter the records that contains Spanish characters?
For example, I had a value in the column name as 'Sureshn '.
My query should return the above folder that contains the Spanish character "N".
Please do the necessary help / advice on that.
Thank you
OraharI don't know what you want, because if you want a? ¢ Analysys and Sureshn, then my previous query is sufficient. However, maybe something like that.
SQL> ed Wrote file afiedt.buf 1 WITH Sample_Data AS (SELECT 'â?¢ Analysys' str FROM DUAL UNION ALL 2 SELECT 'SureshÑ' str FROM DUAL UNION ALL 3 SELECT 'ABCD' str FROM DUAL UNION ALL 4 SELECT 'WXYZ' str FROM DUAL UNION ALL 5 SELECT 'Saubhik' str FROM DUAL 6 ) 7 SELECT str AS "Contains other than English" from Sample_Data 8* WHERE REGEXP_LIKE(str,'[^[a-z,A-Z,0-9]]*') SQL> / Contains other -------------- â?¢ Analysys SureshÑ SQL> ed Wrote file afiedt.buf 1 WITH Sample_Data AS (SELECT 'â?¢ Analysys' str FROM DUAL UNION ALL 2 SELECT 'SureshÑ' str FROM DUAL UNION ALL 3 SELECT 'ABCD' str FROM DUAL UNION ALL 4 SELECT 'WXYZ' str FROM DUAL UNION ALL 5 SELECT 'Saubhik' str FROM DUAL 6 ) 7 SELECT str AS "Contains English" from Sample_Data 8* WHERE NOT REGEXP_LIKE(str,'[^[a-z,A-Z,0-9]]*') SQL> / Contains Engli -------------- ABCD WXYZ Saubhik
-
Hi all
Please I need help with th following question:
WITH some_data LIKE)
SELECT "CNDMNL75P65L736C" FC, "cp" cr, 0 as I1, 1 as I2, I3 OF double 0
UNION ALL
SELECT "PNZGCM74M24L736C", "cp" cr, 5, 0, 0 DOUBLE
UNION ALL
SELECT "," cp, '1', 675,0, 0 DOUBLE cr
UNION ALL
SELECT ", '027113850273' cp," cr, 0, 32, double 0
UNION ALL
SELECT ", '12298850273' cp," cr, 2, 0, 0 DOUBLE
UNION ALL
SELECT ", '35798850273' cp," cr, 0, 12, double 0
UNION ALL
SELECT ", '627771888273' cp," cr, 10, 2, 0 DOUBLE
UNION ALL
SELECT "XDZGCM74M22L736C", "cp" cr, 15, 0, 10 DOUBLE
)
Select * from some_data;
FC CP CR I1 I2 I3 CNDMNL75P65L736C 0 1 0 PNZGCM74M24L736C 5 0 0 1 675 0 0 027113850273 0 32 0 12298850273 2 0 0 35798850273 0 12 0 627771888273 10 2 0 XDZGCM74M22L736C 15 0 10 How can I get a something as; (Only) one record for every 3 rows, like this
CNDMNL75P65L736C 0 1 0PNZGCM74M24L736C 5 0 0 1 675 0 0 (first 3 rows) 027113850273 0 32 0 12298850273 2 0 0 35798850273 0 12 0 (next 3 rows, ) 627771888273 10 2 0 XDZGCM74M22L736C 15 0 10 (and so on )
Thanks in advance
For the 11g version:
WITH some_data AS ( SELECT 'CNDMNL75P65L736C' cf,'' cp ,'' cr, 0 as I1, 1 as I2, 0 as I3 FROM dual UNION ALL SELECT 'PNZGCM74M24L736C' ,'' cp ,'' cr, 5, 0, 0 FROM dual UNION ALL SELECT '' , '' cp ,'1' cr, 675,0, 0 FROM dual UNION ALL SELECT '' , '027113850273' cp ,'' cr, 0 ,32, 0 FROM dual UNION ALL SELECT '' , '12298850273' cp ,'' cr, 2, 0 ,0 FROM dual UNION ALL SELECT '' , '35798850273' cp ,'' cr, 0, 12 ,0 FROM dual UNION ALL SELECT '' , '627771888273' cp ,'' cr, 10, 2 ,0 FROM dual UNION ALL SELECT 'XDZGCM74M22L736C' ,'' cp ,'' cr, 15, 0, 10 FROM dual ) select * from ( select a.*, mod(rownum-1,3)+1 rn, ceil(rownum/3) grp from some_data a ) pivot(max(cf) cf, max(cp) cp, max(cr) cr, max(i1) i1, max(i2) i2, max(i3) i3 for rn in (1 a,2 b,3 c));
GRP A_CF A_CP A_CR A_I1 A_I2 A_I3 B_CF B_CP B_CR B_I1 B_I2 B_I3 C_CF C_CP C_CR C_I1 C_I2 C_I3 1 CNDMNL75P65L736C 0 1 0 PNZGCM74M24L736C 5 0 0 1 675 0 0 2 027113850273 0 32 0 12298850273 2 0 0 35798850273 0 12 0 3 627771888273 10 2 0 XDZGCM74M22L736C 15 0 10 For the 12 c version:
WITH some_data AS ( SELECT 'CNDMNL75P65L736C' cf,'' cp ,'' cr, 0 as I1, 1 as I2, 0 as I3 FROM dual UNION ALL SELECT 'PNZGCM74M24L736C' ,'' cp ,'' cr, 5, 0, 0 FROM dual UNION ALL SELECT '' , '' cp ,'1' cr, 675,0, 0 FROM dual UNION ALL SELECT '' , '027113850273' cp ,'' cr, 0 ,32, 0 FROM dual UNION ALL SELECT '' , '12298850273' cp ,'' cr, 2, 0 ,0 FROM dual UNION ALL SELECT '' , '35798850273' cp ,'' cr, 0, 12 ,0 FROM dual UNION ALL SELECT '' , '627771888273' cp ,'' cr, 10, 2 ,0 FROM dual UNION ALL SELECT 'XDZGCM74M22L736C' ,'' cp ,'' cr, 15, 0, 10 FROM dual ) select * from some_data match_recognize( measures a.cf acf, a.cp acp, a.cr acr, a.i1 ai1, a.i2 ai2, a.i3 ai3, b.cf bcf, b.cp bcp, b.cr bcr, b.i1 bi1, b.i2 bi2, b.i3 bi3, c.cf ccf, c.cp ccp, c.cr ccr, c.i1 ci1, c.i2 ci2, c.i3 ci3 pattern (a b{0,1} c{0,1}) define a as 1=1, b as 1=1, c as 1=1 );
ACF ACP ACR AI1 AI2 AI3 BCF BCP BCR BI1 BI2 BI3 CCF CCP CCR CI1 CI2 CI3 CNDMNL75P65L736C 0 1 0 PNZGCM74M24L736C 5 0 0 1 675 0 0 027113850273 0 32 0 12298850273 2 0 0 35798850273 0 12 0 627771888273 10 2 0 XDZGCM74M22L736C 15 0 10 -
How to filter a static list VO
Hi all
I use Jdev 11.1.1.6 with ADF BC.
Can anyone provide guidance on how to filter a StaticListVO? We cannot have a view of criteria in the same.
Basically my requirement is to filter a LOV static list based on some input values.
I can probably have a Switcher of LOV and 2 static LOVs and switch based on opinions but was looking for a smarter approach that I need to do this in a number of places.
Appreciate your help.
Thank youWhy not create a query based LOV?
Something like
select * from ( select 'value1' ListValue, 'value1' ReturnValue from dual union all select 'value2' ListValue, 'value2' ReturnValue from dual union all select 'value3' ListValue, 'value3' ReturnValue from dual ) where ListValue=:Bind_ListValue
Then pass the connection parameter to filter it.
Arun-
-
Select different columns using union all
I'm trying to select all the records of two table
Select A, B, C from table1
Union of all the
Select A, B, D, E, F from table2
I get results A, B, C columns but not D, E, F.
What should I do to get all the columns in the result. as A, B, C, D, E, F
Thank you
SKHello
That's what you asked for:
select Total_Customer_Qty, NULL AS Total_Supplier_Qty, Item_number, Org,item_id from table1; union all select NULL AS Total_Customer_Qty, Total_Supplier_Qty, Item_number, Org,item_id from table2;
I hope that's what you want, too.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using. -
How to filter data in cursors within the procedure
Hello
Yesterday, I tried all night, but couldn't do it.
I know that is incomplete, I just want to know how to filter the data based on the setting in
Basically, here I want to get only the records that match the id_fichier
create or replace PROCEDURE clearing_details (p_file_id in varchar2)
IS
strStatusCode VARCHAR2 (6);
CURSOR PD1 IS
SELECT COUNTRY_CODE, EOD_MARK OF LINK_STATUS WHERE FILE_ID is p_file_id
Can someone help me on this please:
Thanks for reading.Does do the same if you run the query itself in SQL * Plus with the same value you pass as a parameter?
Without seeing your data and which parameter you're passing, we will fight help more as the concept itself works great as you have been demonstrated.
-
How to filter the modules of the version of TB?
My version of TB: 31.1.2 on Win7
The Add-ons Manager has a section called "Featured addons". I think that, Hey they must be cool if they are featured! I try "Contacts Sidebar" only to discover that it was updated in 2007 and does not support recent versions. How to filter the Add-ons to display only those compatible with my version of TB?
All the people who still use older computers from apple. This is the last version that will run on them.
-
How to filter messages on MCB2300 CAN?
I have an app that gives me that a stack overflow error too CAN traffic. I only need to follow a single message, and if I have only one message on the bus, it works well. As soon as I add the other messages on the bus, I get the error, so I thought I could just remove the ones I haven't read wan't. I put the filter in my code, but I always get a stack overflow when all messages are broadcast. How the filter works The messages go to battery memory first until a software routine has time to cross and filter unwanted messages?
The original request has 1 CAN channel without filtering, and 1 CAPABLE of channeling with filtering. The order of the properties between the 2 CAN channels initialization was not specified in the code and was arbitrarily determined by the compiler. I forced the CAN channel without the filter to initialize before the channel with the filter, and then it works properly.
-
How to create a recovery disc with all vista updates?
original title: how to create a recovery disc with all vista updates without starting from scratch, so I can replace my hard drive?
My hard drive seems to be dying. I would replace the drive. I reloaded vista from scratch with all the updates, but it took forever. I would like to make a record of recovery with all updates. IAM on vista Home premium. 32 bit
If you want a good backup program that backups image, I recommend Acronis True Image 2010:http://www.acronis.com/homecomputing/products/trueimage/. It offers a free trial, so you can test and if you want it's only about $30 for the original version. A lot of people I know this program and use it instead of Vista even in versions of Vista that offers imagery as this program does a better job. Of course you also need a place to put the backup (which will take a lot of space), so also consider. The best choice would be a USB external hard drive at least as large as the readers you want to back up (not only the data on them, but the entire available disk space, so you miss when you add more information about the disks).
You cannot use IMGBURN do - it can't do anything like that. It must be the imagery of backup software.
I hope this helps.
Good luck!
Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.
-
How can I "RECORD each piece of data (and I mean everything!)" contained in the hard disk of the laptop? »
I know PC never fade completely everything, so if there is a way to get personally, I'd really like the head upward on the how to do? I would be better for me to download all this information on a PHDD, rather than handing the portable real in question so that its content of forensics experts, because current 'Communications Network serious security' we have been subjected to.
Here you go:
- Use an imaging program to create a clone of your hard drive.
- Delete the original from your PC hard drive and keep it somewhere safe.
- Put the clone in the PC.
It is the only way to really keep all while still able to use the PC. -
How to transfer/record music off I / tunes to my mp3?
How to transfer/record music of I / tunes to my mp3.
I'm on Windows 8.Thank you very muchJazzSiloh salvation,
Thanks for the reply.
I wish that you move all the music files to the folder my document library in the folder my music library. Now, check if you are able to transfer them to the MP3 player.
What is the brand and model of the MP3 player?
Usually, these players will have their own file transfer software. If you are able to find and install the software for this MP3 player, then you should be able to transfer the songs.
Please, try the following steps and get back to us with the State of the question.
-
SQL query: I want to know how to filter data...
I want to filter these data
year DATA_TYPE product_name amount 2013 1 Apple 100 2013 1 Mango 200 2014 1 Apple 300 2014 1 Mango 150 2014 1 banana 250 2015 1 Apple 350 2015 2 Apple 300 2015 3 Apple 320 2015 2 Mango 400 2015 3 Mango 400 2015 3 banana 500 In each year and each product, I want to filter the data that has no data in data type 1
When he has not given in data of type 1, using data in data type 2.
and if he has not given data type 2, use the data in data of type 3.
This is the result I was expecting
year DATA_TYPE product_name amount 2015 2 Mango 400 2015 3 banana 500 Thanks for your help.
Or more simply...
SQL > ed
A written file afiedt.buf1 with t (year, data_type, product_name, amount) as)
2 Select 2013, 1, 'apple', 100 double Union all
3 select 2013, 1, "mango", 200 double Union all
4 Select 2014, 1, 'apple', 300 double Union all
5 Select 2014, 1, "mango", 150 double Union all
6 select 2014, 1, 'banana', 250 double Union all
7 if he would choose 2015, 1, 'apple', 350 dual Union all
8 select 2015, 2, 'apple', 300 double Union all
9 select 2015, 3, 'apple', 320 double Union all
10. Select 2015, 2, "mango", 400 double Union all
11. Select 2015, 3, "mango", 400 double Union all
12. Select 2015, 3, 'banana', 500 double
13 )
14-
15 end of test data
16-
17 select year
18, max (data_type) keep (first order by data_type dense_rank) as data_type
19, product_name
20, max (amount) to keep (first order by data_type dense_rank) as the amount
21 t
Group 22 by product_name, year
23 * have max (data_type) Dungeon (first order by data_type dense_rank)! = 1
SQL > /.YEAR AMOUNT DATA_TYPE PRODUCTION
---------- ---------- ------ ----------
2015 mango 2 400
2015 banana 3 5002 selected lines.
Maybe you are looking for
-
Siri on MacOS Sierra calls me by name different Contact form
This problem, for me, therefore, with my installation of Siri in MacOS Sierra. He is referring to me, not by my details, but by the coordinates of my wife, which is the entry is the Contacts application above me. I was not able to get Siri to recogni
-
Must remove Ask search engine.
-
Pavilion 15z-ab100: replacement hard drive under warranty outside the country of purchase
Hey everybody. I bought a laptop HP the HP online store in the United States in November 2015. I am currently in India and my laptop hard drive has failed and needs to be replaced. My laptop warranty is valid outside the country of purchase (USA)? Ca
-
HP ProDesk 400 G3 MT: upgrade to Windows 10
Hi all I do everything before upgrade to Windows 10 backup? Looks like I got the answer of difference to this issue. Is it possible, it will be the effect of the system on my pc, such as UBS or SQL funding. ? Thank you. Kind regards Nina
-
"Dell Support" continues to call me
Someone claiming to be the dell support asked my mother's cell phone and our phone at home. They knew even my sisters name, (my sister is one who has first set up the laptop, incidentally) They said that my pc has any suspicious activity that resembl