我想做这样的事情:SELECT @row_number := 1 as row_number,* FROM `users`;SET @row_number = 0;
SELECT @row_number := 1 as row_number,Id, Name,UserName,LastName FROM `users
假设最初的查询是:(但它可以是任意的选择查询)1.它做我需要的事情,但是查询会生成不需要的额外的列row_numberWITH OrderedTable AS SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS row_number, * FROM energy_usage)
SELECT * FROM OrderedTable WHERE row_number BETWEE
使用CASE语句,我可以使用行号按月透视每日总和,但我希望新的列名是实际的任意MONTHID,而不是行号(MONTH_ID1包含ROW_NUMBER 1-12和相应的MONTHID)。select "DAY",sum(case when "ROW_NUMBER) as "3"
,sum(case when &quo