Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Pivot SQL Text columns

$
0
0

Below is the Data format

Table 1 Table 2
Camry_IdMonthYearDealerCamry_Comments Corolla_IdMonthYearDealerCorolla_Comments
172013HendrickCamry Comment 1 172013AutoCityCorolla Comment 1
272013HendrickCamry Comment 2 272013AutoCityCorolla Comment 2
372013HendrickCamry Comment 3 372013AutoCityCorolla Comment 6
472013AutoCityCamry Comment 4 472013LeithCorolla Comment 3
572013AutoCityCamry Comment 5 472013LeithCorolla Comment 8
672013LeithCamry Comment 6 682013LeithCorolla Comment 4
782013LeithCamry Comment 8 872013HendrickCorolla Comment 7
882013LeithCamry Comment 9 

Below is desired result

Result
MonthYearDealerCamry_CommentsCorolla_Comments
72013AutoCityCamry Comment 4Corolla Comment 1
72013AutoCityCamry Comment 5Corolla Comment 2
72013AutoCityCorolla Comment 7
72013HendrickCamry Comment 1Corolla Comment 7
72013HendrickCamry Comment 2
72013HendrickCamry Comment 3
72013LeithCamry Comment 6
72013LeithCorolla Comment 8
82013LeithCamry Comment 8Corolla Comment 4
82013LeithCamry Comment 9































































































Essentially I want to join on month, year and Dealer and display comments in each column aligned. So

if there are comments from both then show both on same like

If one has 2 and other has 1 show first ones on same line; second on next line.Hide duplicates.

It has to show all records(full outer join) from both tables with not multiply or duplicates on either comments column






Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>