我有这样的查询
SELECT ROW_NUMBER() over (order by nomorMahasiswa) AS number
,namaMataKuliah
FROM t_mahasiswa
和像这样的输出
NUMBER LESSON
1 Algoritma dan Pemrograman
2 Pemrograman berorentiasi obyek
3 jaringan
4 Pemrograman Web
5 jaringan
6 jaringan
7 Algoritma dan Pemrograman
8 Algoritma dan Pemrograman
9 algoritma
10 oop
11 oop
12 algoritma
13 algoritma
14 algoritma
我想在INFORMIX 11.50中进行类似的查询,我该怎么办?
答案 0 :(得分:0)
此语法在版本11.50中不可用11.70 这里可行的选项是创建自己的UDR(用户定义的例程=过程)来模拟情况。
会有一些限制......
这是我的row_number版本....
create procedure row_number(initial integer) returning integer as row_number;
define global i integer default 0;
if initial = 0 then
let i = 0;
return 0 ;
end if;
let i = i+1;
return i ;
end procedure
document "Simplified and similar function to row_number() from SqlServer.",
"Need to reset the counter before each sql statement with ",
"execute procedure row_number(0) OR declare into FROM clause",
"For use in SELECT statement use any other number in parameter:",
"select row_number(1) , tabname from systables;",
"OR select row_number(1) , tabname from systables, table(row_number(0))",
"By Cesar Inacio Martins - www.imartins.com.br"
with listing in "/tmp/row_number.out"
;
Routine created.
;
-- Here the syntax of call should always be the same, row_number(1) to
-- the field and table(row_number(0)) for table
select first 5 row_number(1), tabname::char(20)
from systables, table(row_number(0));
(expression) (expression)
1 systables
2 syscolumns
3 sysindices
4 systabauth
5 syscolauth
5 row(s) retrieved.
select first 5 row_number(1), tabname::char(20)
from systables, table(row_number(0))
order by 1 desc;
(expression) (expression)
245 SMIVERSION
244 sysextspaces
243 syscompdicts
242 syscmsm
241 syssqexplain
5 row(s) retrieved.