如何将四个选择的查询合并为一个?

时间:2017-02-28 10:35:44

标签: sql sybase

我有四种不同的选择查询。

Select A,Round(B) as P,Round(C) as Q,Round(D) as R,Round(E) as S from tb_name1 a Inner Join tb_name2 b on (a.X1 =b.X2 and a.T_KEY=b.T_KEY) where a.X3="something" and a.X4="xyz" and b.X5="1243" GROUP BY A ORDER BY A DESC

Select A,Round(F) as T from tb_name4 a Join tb_name5 b on (a.K1 = b.K2 and a.K3 and b.K4 ) where a.X6="something" and a.X7="xyz1" and b.X8="1233" GROUP BY A ORDER BY A DESC

Select A,Round(G) as Q from tb_name6 a Join tb_name7 b on (a.K5 = b.K6 and a.K7 and b.K8 ) where a.X9="something" and a.X10="xyz2" and b.X11="123" GROUP BY A ORDER BY A DESC

Select A,Round(H) as R from tb_name8 a Join tb_name9 b on (a.K9 = b.K10 and a.K11 and b.K12 ) where a.X12="something" and a.X13="xyz3" and b.X14="1123" GROUP BY A ORDER BY A DESC

我已尝试使用Union但它无法正常工作。我希望使用四个查询输出一个输出,并且值应显示为一个接一个的值,如下所示......

输出: -

Column's Name  Column1  Column2  Column3  Column4  Column5   Column6   Column7 

Row 1          valu1    valu2    valu3     valu4    valu5     valu6    valu7 

Row 2          valu8    valu9    valu10    valu11   valu12    valu13   valu14 

Row 3          valu15   valu16   valu17    valu18   valu19    valu20   valu21 

0 个答案:

没有答案