Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
xclaim
Starting Member
8 Posts |
Posted - 2013-12-18 : 17:18:40
|
trying to get the following output but struggling with it :output site parent child site parent childA 1234 C3348 B 1234 C3348 B 1234 C9999A 1234 C3349 B 1234 C3349A 1234 C3350 B 1234 C3350A 1234 C3351 B 1234 C3351A 1234 C3352 data site parent child A 1234 C3348 A 1234 C3349 A 1234 C3350 A 1234 C3351 A 1234 C3352 B 1234 C3348 B 1234 C9999 B 1234 C3349 B 1234 C3350 B 1234 C3351 pls help |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-12-19 : 03:36:32
|
[code]SELECT t1.*,t2.*FROM Table t1FULL OUTER JOIN Table t2ON t2.parent = t1.parentAND t2.child = t1.child[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
xclaim
Starting Member
8 Posts |
Posted - 2013-12-27 : 21:48:12
|
quote: Originally posted by visakh16
SELECT t1.*,t2.*FROM Table t1FULL OUTER JOIN Table t2ON t2.parent = t1.parentAND t2.child = t1.child ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
thank you this works |
|
|
xclaim
Starting Member
8 Posts |
Posted - 2013-12-27 : 21:53:04
|
new request as a follow on to the above one ....here is the sample setsite parent childA 1234 C3348A 1234 C3349A 1234 C3350A 1234 C3351A 1234 C3352B 1234 C3348B 1234 C9999B 1234 C3349B 1234 C3350B 1234 C3351A 1235 C3322A 1235 C5567A 1235 C7789A 1235 C9987B 1235 C3322B 1235 C5567B 1235 C7789B 1235 C9987 i need the same results as my first results above i.eoutput site parent child site parent childA 1234 C3348 B 1234 C3348 B 1234 C9999A 1234 C3349 B 1234 C3349A 1234 C3350 B 1234 C3350A 1234 C3351 B 1234 C3351A 1234 C3352 so the 1235 parent and childs will not need to result because the data-sets are similar in both sites.. i only want to see the deltas.thanks much. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-12-28 : 03:16:26
|
[code];With CTEAS(SELECT t1.site AS Asite,t1.parent AS Aparent,t1.child AS Achild,t2.site AS Bsite,t2.parent AS Bparent,t2.child AS BchildFROM Table t1FULL OUTER JOIN Table t2ON t2.parent = t1.parentAND t2.child = t1.child)SELECT Asite,Aparent,Achild,Bsite,Bparent,BchildFROM(SELECT *,SUM(CASE WHEN Asite IS NULL OR Bsite IS NULL THEN 1 ELSE 0 END) OVER (PARTITION BY COALESCE(Aparent,Bparent),COALESCE(Achild,Bchild)) AS CntFROM CTE)tWHERE Cnt > 0[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|