oracle 一条数据分割为多条记录(oracle 怎么把一个字段的值分成多个字段显示)

1、问题:金额是计算 "应收款shoukuan"吗?旅游天数和编团部门从哪个表字段取值(我猜是从”编团表“)?

2、select a.tuanhao "团号",b.lname "线路",


(资料图)

3、b.旅游天数,b.编团部门,

4、sum(decode(shenfen,"成人",1,0)) "成人-人数",

5、sum(decode(shenfen,"成人",shoukuan,0)) "成人-金额",

6、sum(decode(shenfen,"占床小童",1,0)) "占床小童-人数",

7、sum(decode(shenfen,"占床小童",shoukuan,0)) "占床小童-金额",

8、sum(decode(shenfen,"不占床小童",1,0)) "不占床小童-人数",

9、sum(decode(shenfen,"不占床小童",shoukuan,0)) "不占床小童-金额",

10、sum(decode(shenfen,"老人",1,0)) "老人-人数",

11、sum(decode(shenfen,"老人",shoukuan,0)) "老人-金额",

12、sum(decode(shenfen,"婴儿",1,0)) "婴儿-人数",

13、sum(decode(shenfen,"婴儿",shoukuan,0)) "婴儿-金额",

14、sum(decode(shenfen,"VIP",1,0)) "VIP-人数",

15、sum(decode(shenfen,"VIP",shoukuan,0)) "VIP-金额",

16、sum(shoukuan) "金额合计" --如果成人、占床小童、不占床小童、老人、婴儿、VIP是你所有的shenfen就可以这样写,如果还有其它的,就把上面的加起来

17、from 编团-游客中间表 a,编团表 b

18、where a.tlneid=b.lid

19、group by a.tuanhao,b.lname,b.旅游天数,b.编团部门

本文到此讲解完毕了,希望对大家有帮助。

标签:

X 广告
X 广告

Copyright ©  2015-2022 南极舞蹈网版权所有  备案号:粤ICP备2022077823号-13   联系邮箱: 317 493 128@qq.com