是否有与 UniQuery SAMPLE 关键字等效的 UniData SQL?
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,没有,似乎没有与 UniQuery SAMPLE 关键字等效的 UniSQL。 UniSQL 由 ANSI SQL-92 标准的子集组成,并具有一些支持多值的扩展。但是,ANSI SQL-92 不包含限制查询返回的结果集的标准,这就是为什么不同的 DBMS 具有不同的语法来执行此操作。
ANSI SQL-2008 添加了 FETCH FIRST 子句是实现查询返回行数限制的标准方法。需要进行相当重大的更新才能使 UniSQL 达到最新标准,因为它现在已经落后了 20 多年。用户社区似乎没有足够大的需求来承担这项工作。
根据您的文件架构,您也许可以应用解决方法。如果您使用自动递增键,则可以使用如下语法:
上述查询将对返回的行数应用事实上的限制。
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:
The above query would be apply a de facto limit to the number of rows returned.
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.