Select IF(RowNumber = 1, Location, null) As Location, Name From yourtable
GoodLuck
Date :
2014-04-19 11:31:55
By :
love9713
No. 7
Guest
จาก #NO 6 ขยายความ RowNumber
เผื่อจะเป็นประโยชน์สำหรับผู้ที่ผ่านไปผ่านมาบ้าง
Code (SQL)
Select '' As Location, '' As Name
Union All
Select If(temp.RowNumber = 1, Location, null) As Location, Name From (Select
@i := If(@j != Location, 1, @i + 1) As RowNumber,
@j := Location,
Location, Name
From
yourTable,
(Select @i := 0) dummyA,
(Select @j := null) dummyB
Order By Location) temp