qyx0714
2015-02-09 01:00
采纳率: 50%
浏览 2.1k

SQL 列转行如何实现?

图片说明 这种什么实现?我的语句是:select ISNULL(fritemcd,tofritemcd)as fritemcd, qty,qty2 from
(SELECT a.fritemcd,a.qty FROM iniop03t a
left join biitm01t b on fritemcd=itemcd
WHERE a.movedt='20150204' AND a.frstockcd IN ('A710','A711','A713','a712' )and b.itemkind='2') T
full join
(SELECT a.fritemcd tofritemcd,a.qty as qty2 FROM iniop03t a --入
left join biitm01t b on fritemcd=itemcd
WHERE movedt='20150204' AND tostockcd IN ('A710','A711','A713','a712') and b.itemkind='2')F on T.fritemcd=F.tofritemcd

结果如下:图片说明

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题