Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我不知道如何用文字来解释我想要什么,所以我附上了一张解释它的图片:
我应该用 SQL 编写哪个命令来执行此操作?
我不知道 stackexchange 还想让我做什么来发布问题,所以我添加了这句话。
select set_id, num, case when type_id = 1 then id end as id_1, case when type_id = 2 then id end as id_2, case when type_id = 3 then id end as id_3 from your_table group by set_id, num