当前位置: 代码迷 >> Sql Server >> SQL 把两个表给拼下床
  详细解决方案

SQL 把两个表给拼下床

热度:80   发布时间:2016-04-24 10:43:15.0
SQL 把两个表给拼起来
如下图:


如何把这两个表给拼接起来呢?
如果我用 
select * from ()a , () b

可得到的结果是196条数据

我的期望是 
14条数据,两列




select 
Package_Rate    R_邓波   
from hub_target_detail
where name = '邓波' and date = 20140514

union all 

select 
MoldIssue_Rate    R_邓波   
from hub_target_detail
where name = '邓波' and date = 20140514


union all 

select 
PlateRec_Rate    R_邓波   
from hub_target_detail
where name = '邓波' and date = 20140514



union all 

select 
NoAirPack_Rate    R_邓波   
from hub_target_detail
where name = '邓波' and date = 20140514



union all 

select 
ScrapRec_Rate    R_邓波   
from hub_target_detail
where name = '邓波' and date = 20140514



union all 

select 
PartIssue_Rate    R_邓波   
from hub_target_detail
where name = '邓波' and date = 20140514


union all 


select 
J_Rate    R_邓波   
from hub_target_detail
where name = '邓波' and date = 20140514


union all 


select 
O_Rate    R_邓波   
from hub_target_detail
where name = '邓波' and date = 20140514


union all 


select 
OLable_Rate    R_邓波   
from hub_target_detail
where name = '邓波' and date = 20140514


union all 


select 
OLoading_Rate    R_邓波   
from hub_target_detail
where name = '邓波' and date = 20140514


union all 


select 
JPack_Rate    R_邓波   
from hub_target_detail
where name = '邓波' and date = 20140514


union all 


select 
Shipping_Rate    R_邓波   
from hub_target_detail
where name = '邓波' and date = 20140514



union all 

select 
JLoading_Rate    R_邓波     
from hub_target_detail
where name = '邓波' and date = 20140514


union all 

select 
Chamfer_Rate    R_邓波   
from hub_target_detail
where name = '邓波' and date = 20140514

------------------------------================================== =====================

select 
Package_Rate    R_王龙龙   
from hub_target_detail
where name = '王龙龙' and date = 20140514

union all 

select 
MoldIssue_Rate    R_王龙龙   
from hub_target_detail
where name = '王龙龙' and date = 20140514


union all 

select 
PlateRec_Rate    R_王龙龙   
from hub_target_detail
where name = '王龙龙' and date = 20140514



union all 

select 
NoAirPack_Rate    R_王龙龙   
from hub_target_detail
where name = '王龙龙' and date = 20140514



union all 

select 
ScrapRec_Rate    R_王龙龙   
from hub_target_detail
where name = '王龙龙' and date = 20140514



union all 

select 
PartIssue_Rate    R_王龙龙   
from hub_target_detail
where name = '王龙龙' and date = 20140514


union all 


select 
J_Rate    R_王龙龙   
from hub_target_detail
where name = '王龙龙' and date = 20140514


union all 


select 
O_Rate    R_王龙龙   
from hub_target_detail
where name = '王龙龙' and date = 20140514


union all 


select 
OLable_Rate    R_王龙龙   
from hub_target_detail
where name = '王龙龙' and date = 20140514


union all 


select 
  相关解决方案