sql server - Merging results in T-SQL statement -


I have to ask:

  Choose a name from the ID, name, pending ID, name, Number 1, First, 1, 3, Third, 12  
  Select the full id, name, number 1, before, 100 2, second, 20, id, name, number  

I want output to combine them, probably like a pivot table using T-SQL

  id, name pending, complete , Total 1, first, 1, 100, 101 2, second, blank, 20, 20 3, third, 12, zero, 12  

How can this be written?

No need for pivot.

  SELECT COALESCE (p.id, c.id), COALESCE (P. name, CNN), PNM Pending, c.num AS complete, COALESCE (p.num, 0) + COALESCE (c.num, 0) P.ID = Seed completed on completion of the completed P in the total outcome as complete.  

The coal is ANSI SQL but you can also use ISNULL


Comments