April 15, 2009 at 11:30 am
I have one table name CALIMS and i want to select 2 columns
SELECT RID ,DATE
FROM CALIMS
WHERE DAG='Y'
and again want to select the data from the same same talbe without any condtions
SELECT RID ,DATE
FROM CALIMS
and i want to combine the resultset ....in the final result i want the data from 1st select statement and in the second select stmt i want the data after eliminating the (1st select stmt data)
Thanks
April 15, 2009 at 11:38 am
dheer (4/15/2009)
I have one table name CALIMS and i want to select 2 columnsSELECT RID ,DATE
FROM CALIMS
WHERE DAG='Y'
and again want to select the data from the same same talbe without any condtions
SELECT RID ,DATE
FROM CALIMS
and i want to combine the resultset ....in the final result i want the data from 1st select statement and in the second select stmt i want the data after eliminating the (1st select stmt data)
Thanks
Well this is very straightforward!
SELECT RID ,DATE
FROM CALIMS
This will give you exactly what you have asked for - the result of the first query, combined with (the whole table minus the result of the first query)!
I think you may wish to restate your requirement:-D
Cheers
ChrisM
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
April 15, 2009 at 2:22 pm
Hi
I also don't really understand the requirement. Do you mean that you want to append the filtered result with the unfiltered one? (What I still wouldn't understand π ) If yes just write "UNION ALL" between the both statements.
Greets
Flo
April 16, 2009 at 7:25 am
Florian Reischl (4/15/2009)
HiI also don't really understand the requirement. Do you mean that you want to append the filtered result with the unfiltered one? (What I still wouldn't understand π ) If yes just write "UNION ALL" between the both statements.
Greets
Flo
I actually think the OP wants to use the UNION statement based on this (bolding added by me):
.in the final result i want the data from 1st select statement and in the second select stmt i want the data after eliminating the (1st select stmt data)
UNION will eliminate duplicate results while UNION ALL will keep duplicates (this is for the OP not you Flo, as I am sure you know this already).
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
April 16, 2009 at 8:34 am
Jack Corbett (4/16/2009)
Florian Reischl (4/15/2009)
HiI also don't really understand the requirement. Do you mean that you want to append the filtered result with the unfiltered one? (What I still wouldn't understand π ) If yes just write "UNION ALL" between the both statements.
Greets
Flo
I actually think the OP wants to use the UNION statement based on this (bolding added by me):
.in the final result i want the data from 1st select statement and in the second select stmt i want the data after eliminating the (1st select stmt data)
Hi Jack
Thanks! I skipped the part with the elimination. So the UNION is the correct (or as Chris already posted just the query without any criteria π ).
Greets
Flo
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply