从这段代码可以得出,对于locationid 5,6,7,8,它将在第二行而不是它继续?将行转换为mysql v3中的列
SELECT
MAX(case when locationid = '1' then floatvalue end) Flow,
MAX(case when locationid = '2' then floatvalue end) Level,
MAX(case when locationid = '3' then floatvalue end) Pressure,
MAX(case when locationid = '4' then floatvalue end) MR,
MAX(case when locationid = '5' then floatvalue end) Flow,
MAX(case when locationid = '6' then floatvalue end) Level,
MAX(case when locationid = '7' then floatvalue end) Pressure,
MAX(case when locationid = '8' then floatvalue end) MR
FROM table
因此,不是这样的:
Flow | Level | Pressure | MR | Flow | Level | Pressure | MR |
10 | 20 | 30 | 40 | 100 | 200 | 300 | 400 |
它会是这样的:
Flow | Level | Pressure | MR |
10 | 20 | 30 | 40 |
100 | 200 | 300 | 400 |
没有。你不能在sql中写一些能从一个记录生成两条记录的东西。如果你想显示两行,那么把这个逻辑放到客户端软件中。 –