mysql语句,两条记录合并为一条,且以有值的列作为记录
这是查询到的结果。合并后的值应该为”2010-02-0100:00:00.000-181“这是我写的sql语句:SELECTydt_booking_id,ydt_date...
这是查询到的结果。合并后的值应该为 ”2010-02-01 00:00:00.000 -18 1“
这是我写的sql语句:
SELECT ydt_booking_id,ydt_date,
MAX(case industry_type when 'AIR' then net_bill_bookings else 0 end) as net_bill_bookingsA,
MAX(case industry_type when 'HTL' then net_bill_bookings else 0 end) as net_bill_bookingsH
FROM ydt_booking AS g INNER JOIN dbo.customer AS b ON g.sid = b.sid_1p WHERE b.sid_1p = '89C' AND ydt_date = '2010-02-01' GROUP BY ydt_date,ydt_booking_id
我写的这个sql语句有问题,这样只是取到最大值的那个列合并了。 展开
这是我写的sql语句:
SELECT ydt_booking_id,ydt_date,
MAX(case industry_type when 'AIR' then net_bill_bookings else 0 end) as net_bill_bookingsA,
MAX(case industry_type when 'HTL' then net_bill_bookings else 0 end) as net_bill_bookingsH
FROM ydt_booking AS g INNER JOIN dbo.customer AS b ON g.sid = b.sid_1p WHERE b.sid_1p = '89C' AND ydt_date = '2010-02-01' GROUP BY ydt_date,ydt_booking_id
我写的这个sql语句有问题,这样只是取到最大值的那个列合并了。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询