-- 创建临时表
CREATE TEMPORARY TABLE temp1 AS ( SELECT (@rowindex := @rowindex +1) AS rowindex,a.city_id,b.name as 'city_name' ,a.dept_name,a.final_point
FROM aqjd_assessment_dept a
JOIN sys_city b on a.city_id = b.id
JOIN (SELECT (@rowindex := 0)) c -- rowindex 初始化
WHERE a.city_station =1
ORDER BY a.final_point DESC
);
标签:index,name,city,rowindex,point,sqlserver,查询,id From: https://www.cnblogs.com/wqw553639736/p/17727606.html