我有下表,並且試圖根據id對行進行分組。我希望能夠返回所有類型包含S和A的情況下的相同ID(a19),但不返回S或A互不存在的情況(a22 & a33)。 這樣做最簡單的方法是什麼? +---+----+--------------+
|id |type| text |
+---+----+--------------+
a19 S S1
a19 A A1
a19 A A1
a
列我有產生以下結果一個簡單的查詢: SELECT month,transporttype,count(transporttype) as loads
from deliveries
group by month,transporttype
我想行轉置成列。 我知道mysql沒有pivot函數,所以需要union但不是100%肯定。 在此先感謝您的幫助。