求指点!这个该怎么写
如
id aid
1 0
2 1
3 0
4 1
用sql查出来这样
id aid
1 b
2 c
3 b
4 c
(别让我去操作数据集,只想知道sql怎么整,求指点)
[解决办法]
select id,case when aid=0 then 'b' when aid=1 then 'c' end as aid
from T
[解决办法]
0和b,1和C之间有什么关系么?规律?
是不是2就是d?
[解决办法]
SELECT id , aidFROM ( SELECT id , 'b' AS 'aid' FROM TB WHERE id % 2 = 1 UNION SELECT id , 'c' AS 'aid' FROM TB WHERE id % 2 = 0 ) TORDER BY id ASC