從這段代碼可以得出,對於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中寫一些能從一個記錄生成兩條記錄的東西。如果你想顯示兩行,那麼把這個邏輯放到客戶端軟件中。 –