急急急!数据库是Sql Anywhere,求该月(比如11月)的费用前100名的用户和100名固定用户的并集(union),用的是存储过程实现的,但在数据量大的时候就retrieve不出来,小的时候(把100换成10)就没有问题,请问怎么解决?

lee_lee 2001-11-26 03:47:34
急急急!数据库是Sql Anywhere,求该月(比如11月)的费用前100名的用户和100名固定用户的并集(union),用的是存储过程实现的,但在数据量大的时候就retrieve不出来,小的时候(把100换成10)就没有问题,请问怎么解决?
...全文
59 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
killerdanny 2001-11-26
  • 打赏
  • 举报
回复
TOP 我在ASA7中支持的 !
//下面是帮助asa7的帮助
Retrieving the first few rows of a query

--------------------------------------------------------------------------------

You can limit the results of a query to the first few rows returned using the FIRST or TOP keywords. While you can use these with any query, they are most useful with queries that use the ORDER BY clause.

Examples
The following query returns information about the first employee sorted by last name:

SELECT FIRST *
FROM employee
ORDER BY emp_lname
The following query returns the first five employees sorted by last name comes earliest in the alphabet:

SELECT TOP 5 *
FROM employee
ORDER BY emp_lname

--------------------------------------------------------------------------------
lee_lee 2001-11-26
  • 打赏
  • 举报
回复
to killerdanny(danny):
感觉存储过程性能要优良一些
但是你的top 100在Sql Anywhere中支持吗?你试过没有?我试过,没有成功。
killerdanny 2001-11-26
  • 打赏
  • 举报
回复
SELECT TOP 100 ID
FROM TABLE1
WHERE 条件
union
SELECT top 100 id
from table2
WHERE 条件
//为什么要用SP?上面的写错了!
killerdanny 2001-11-26
  • 打赏
  • 举报
回复
SELECT TOP 100 ID
FROM TABLE1
WHERE DATE=11
union top 100 id
from table2
WHERE DATE=11
///你是这样的SELECT吗?!

754

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧