December 10, 2014 at 3:04 pm
Hi.
Here is an example of what I need:
select A.name,B.address,A.case
from A
inner join B on A.ID = B.ID
where case like '%AA%'
select A.name,B.address,A.case
from A
inner join B on A.ID = B.ID
where case like '%BB%'
This will give two results as:
Name Address Case
A texas AA-109090
B IL AA-109091
Name Address Case
A texas cc-109090
B IL cc-109091
I need results like:
AACase CCCase
AA-109090 cc-109090
AA-109091 cc-109091
how can I achieve the above result ?
December 10, 2014 at 3:12 pm
How much do you know about using Integration Services?
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
December 10, 2014 at 3:17 pm
I tried with SSIS using two datasources and using the same excel destination
But it resulted as
AACase CCCase
cc-109090
cc-109091
AA-109090
AA-109091
But I want result like this :
AACase CCCase
AA-109090 cc-109090
AA-109091 cc-109091
December 11, 2014 at 1:05 am
First, I am assuming that you confused 'BB' and 'CC' in your sample data and query.
It would probably be easier to use T-SQL to get your data into the required format and then use that as your source query.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
December 11, 2014 at 7:23 am
No, that is what I wanted just the casenumbers. How do I do in sql using unpivot?
December 11, 2014 at 7:33 am
Phil Parkin (12/11/2014)
First, I am assuming that you confused 'BB' and 'CC' in your sample data and query.It would probably be easier to use T-SQL to get your data into the required format and then use that as your source query.
I agree.
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
December 11, 2014 at 8:18 am
I am able to get till this:
AACaseCCCase
NULL CC-109090
NULL CC-109091
AA-109090 NULL
AA-109091 NULL
Is there way I can get result in this format:
AACaseCCCase
AA-109090CC-109090
AA-109091CC-109091
December 11, 2014 at 9:08 am
First, I am assuming that you confused 'BB' and 'CC' in your sample data and query.
No, that is what I wanted just the casenumbers.
Really? Your sample query includes this WHERE clause:
where case like '%BB%'
And yet your sample data includes this 'case':
cc-109090
Please explain how your WHERE clause can ever select this data.
Moving on ...
Try running this. Should give you an idea how to get the data you want:
with data
as (
select name = 'A'
,cse = 'AA-109090'
union
select name = 'A'
,cse = 'CC-109090'
)
select AA = max(case when d.cse like 'AA%' then d.cse
else ''
end)
,CC = max(case when d.cse like 'CC%' then d.cse
else ''
end)
from data d
group by d.name
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply