I want to compare two sets of data and display the whole union of two sets, plus add column A line set appears in 1, 2 sets, or both. I am working in T-SQL
Table A | [ID] | | [Movie] | [Years] | | ----- | --------- | -------- | | 1 | Movie 1 Year 1 | | 2 | Movie 2 | Year 2 | | 3 | Movie 3 | Year 3 Table b [ID] | [Movie] | [Years] | | ----- | --------- | -------- | | 2 | Movie 2 | Year 2 | | 3 | Movie 3 | Year 3 | 4 | Movie 4 | Year 4 Desired Results: | [ID] | [Movie] | [Years] | [Set in]? | [Set B in]? | | ----- | --------- | -------- | ------------- | ---------- --- | | 1 | Movie 1 Year 1 | Yes. No | | 2 | Movie 2 | Year 2 | Yes. Yes. | 3 | Movie 3 | Year 3 Yes. Yes. | 4 | Movie 4 | Year 4 No | Yes. Is it possible to complete in SQL? I will create just one column to get the added column where the output was A, B or both.
You can use a full zone and coal, it is believed that you are included on the ID Can be:
SELECT COALESCE (a.ID, b.ID) as ID, COALESCE (a.movie, b.mo), as a film, coal (aure) , Beer) as a matter of year, when the AIID tap ends in 'no' or 'ESESTA', when BIID is zero 'ALSE' Yes 'table' from INSAT B as 'end' A full entry table at A B AID = BID Demo:
You can also add the last part in a field:
SELECT COALESCE ( In the form of Movie, Collages (AIE, B -E) as AIID, BID ID, Coles (A.M.V., B.M.), in the form of a year, case when AIID void If 'B' is zero, then 'only' in 'only' will be added to the table in the end of both tables as a complete tableb b on a.ID = b .ID < / Pre>
No comments:
Post a Comment