是否有与 UniQuery SAMPLE 关键字等效的 UniData SQL?

发布于 2024-12-02 14:57:47 字数 424 浏览 3 评论 0原文

我正在使用 UniData 6。是否有与 UniQuery SAMPLE 关键字等效的 UniData SQL?

使用 UniQuery,我一直能够做到:

SELECT CUST BY NAME SAMPLE 1 

它会给我第一个字母名称的记录。

在 UniData SQL 中,我希望能够执行以下操作:

SELECT NAME FROM CUST ORDER BY NAME SAMPLE 1; 

...或者像在其他 SQL 数据库中一样...

SELECT TOP 1 NAME FROM CUST ORDER BY NAME; 

并仅获取按字母顺序列出的第一个客户的姓名。有这样的关键字吗?

I'm using UniData 6. Is there a UniData SQL equivalent to the UniQuery SAMPLE keyword?

Using UniQuery, I've always been able to do:

SELECT CUST BY NAME SAMPLE 1 

and it would give me the record with the first alphabetical name.

In UniData SQL, I'd like to be able to do something like:

SELECT NAME FROM CUST ORDER BY NAME SAMPLE 1; 

...or, as in other SQL databases...

SELECT TOP 1 NAME FROM CUST ORDER BY NAME; 

and get just the name of the the customer who's listed first alphabetically. Is there a keyword like this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白鸥掠海 2024-12-09 14:57:47

不幸的是,没有,似乎没有与 UniQuery SAMPLE 关键字等效的 UniSQL。 UniSQL 由 ANSI SQL-92 标准的子集组成,并具有一些支持多值的扩展。但是,ANSI SQL-92 不包含限制查询返回的结果集的标准,这就是为什么不同的 DBMS 具有不同的语法来执行此操作。

ANSI SQL-2008 添加了 FETCH FIRST 子句是实现查询返回行数限制的标准方法。需要进行相当重大的更新才能使 UniSQL 达到最新标准,因为它现在已经落后了 20 多年。用户社区似乎没有足够大的需求来承担这项工作。

根据您的文件架构,您也许可以应用解决方法。如果您使用自动递增键,则可以使用如下语法:

SELECT foo
FROM bar
WHERE @ID <= 10

上述查询将对返回的行数应用事实上的限制。

Unfortunately, no, there does not appear to be a UniSQL equivalent to the UniQuery SAMPLE keyword. UniSQL consists of a subset of ANSI SQL-92 standards, with some extensions to support multivalue. However, ANSI SQL-92 does not contain a standard for limiting the result set returned from a query, which is why various DBMS have different syntax for doing so.

ANSI SQL-2008 added the FETCH FIRST clause which is the standard way of implementing a limit to the number of rows returned by a query. It would require a pretty significant update to bring UniSQL up to recent standards since it is now 20+ years behind. There doesn't seem to be significant enough demand in the user community to undertake that effort.

Depending on your file's schema, you may be able to apply a workaround. If you are using an auto-incrementing key, you could use a syntax such as:

SELECT foo
FROM bar
WHERE @ID <= 10

The above query would be apply a de facto limit to the number of rows returned.

怪我入戏太深 2024-12-09 14:57:47

SELECT 通常仅适用于记录 ID。如果您想列出属性,请尝试 LIST:LIST INVENTORY PROD_NAME PRICE QTY SAMPLE 例如,将返回前 10 个产品名称、价格和数量。

SELECT will usually only apply to record IDs. If you want to list out attributes, try LIST: LIST INVENTORY PROD_NAME PRICE QTY SAMPLE for instance will return the first 10 product names, prices and quantities.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文