如何在sybase查询中设置行号 [英] how to set row number in sybase query

查看:42
本文介绍了如何在sybase查询中设置行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个选择语句,它将返回结果说 1000 使用连接与一些 3 到 4 个表.我的要求是在结果集中有标识列.任何人都可以帮助我.

I have a select statemnt which will return results say 1000 using join with some 3 to 4 tables. My requirement is to have identity column in the resultset . Can anyone help me on this.

例如:

Result :
id   name 
--   ----
001   xxx
002   yyy
003   zzz

My requirment :
Rowid   id   name 
 1      --   ----
 2       001   xxx 
 3       002   yyy
 4       003   zzz

就像 sql 中的 Row_number 一样,sybase 里有什么东西吗

Like Row_number in sql , do we have anything here in sybase

推荐答案

在 sybase 中没有 row_number 或类似的东西.也许带有标识列的临时表会对您有所帮助?

In sybase there isn't row_number or something like that. Maybe temporary tables with identity column will help you?

请考虑以下示例.

 select Rowid = identity(8), id, name      
 into #temtab
 from tab

 select Rowid, id, name
 from #temtab

这篇关于如何在sybase查询中设置行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆