现有表如下:
id time is_login
3 2012-07-03 11:20:20 1
3 2012-07-03 11:25:20 0
4 2012-07-03 12:30:20 1
4 2012-07-03 12:20:50 0
需要的效果:
id login_ time logout_time
3 2012-07-03 11:20:20 2012-07-03 11:25:20
4 2012-07-03 12:20:20 2012-07-03 12:30:50
实现语句:
SELECT
`order`,
MAX(
CASE money_type
WHEN '2' THEN
amount
END
) AS yuepay,
MAX(
CASE money_type
WHEN '1' THEN
amount
END
) AS wxpay
FROM
hbj_aa_user_account
WHERE
`ORDER` = 325
GROUP BY
`ORDER`