展开全部
我用的PLSQL,应该没啥不同吧
源SQL
SELECT *
FROM (SELECT row_number() over(/*PARTITION BY var_common2*/ ORDER BY num_common1 DESC) AS pai,
/*a.var_common2,*/
a.var_common1,
a.num_common1
FROM cux_gj_common_t a) a
WHERE a.pai <= 3;
--开窗函32313133353236313431303231363533e58685e5aeb931333363356634数实现方式
BEGIN
INSERT INTO cux_gj_common_t(type_name,var_common1,var_common2,num_common1) VALUES ('测试','','新闻',15);
INSERT INTO cux_gj_common_t(type_name,var_common1,var_common2,num_common1) VALUES ('测试','','新闻',60);
INSERT INTO cux_gj_common_t(type_name,var_common1,var_common2,num_common1) VALUES ('测试','','新闻',100);
INSERT INTO cux_gj_common_t(type_name,var_common1,var_common2,num_common1) VALUES ('测试','','新闻',100);
INSERT INTO cux_gj_common_t(type_name,var_common1,var_common2,num_common1) VALUES ('测试','','新闻',80);
INSERT INTO cux_gj_common_t(type_name,var_common1,var_common2,num_common1) VALUES ('测试','','新闻',99);
END;