0
SELECT DISTINCT Id, AppStatusId,
IF ((AppStatusId = 80),"1","2") as res
#(here i need res as "1" if AppStatusId = 80 for first 100 rows )
FROM App
WHERE
AppStatusId = 80
or
AppTypeId = 100
行的查询返回1000查询,我想获得RES列1为前100行与条件AppStatusId = 80.我期待以下结果
Id, AppStatusId,res
14343 ,80 , ,1
2234 ,80 , ,1
3232 ,80 , ,1
..................
..................
..................
..................
8975, 80, ,1 # 100th row
3232, 80, ,0
102, 80, ,0
103, 80, ,0
..................
..................
222, 55, ,0 (becuase of or AppTypeId = 100 in where condition)
记得你必须别名子查询;) –
这也是'CROSS JOIN(SELECT @rn = 0)' –
@JuanCarlosOropeza是的,谢谢你在打字的时候发现了。谢谢! – Matt