0

我在对 interbase 中的数据进行排序时遇到问题,我的时间戳位于年、月、日等的单独列中,因此我需要按该顺序排序(尽管在这种情况下,即使按单个字段排序也行不通) . 由于某种原因,当与 CREATE VIEW 或 INSERT INTO 结合使用时,ORDER 命令会引发“令牌未知”错误。我在这里犯了一个愚蠢的语法错误,还是我尝试使用 ORDER 命令的方式存在更根本的问题?

CREATE VIEW HOURLY_AVES_SORT (MEASYEAR,MEASMONTH,MEASDAY,MEASHOUR,GH,GK,GDH,TA) as
SELECT
  HOURLY_AVES_ALL.MEASYEAR, HOURLY_AVES_ALL.MEASMONTH, HOURLY_AVES_ALL.MEASDAY,
  HOURLY_AVES_ALL.MEASHOUR, /*HOURLY_AVES.MEASMIN, HOURLY_AVES_ALL.MEASSECOND, */
  HOURLY_AVES_ALL.GH, HOURLY_AVES_ALL.GK, HOURLY_AVES_ALL.GDH, HOURLY_AVES_ALL.TA

FROM HOURLY_AVES

ORDER BY
   HOURLY_AVES_ALL.MEASYEAR, HOURLY_AVES_ALL.MEASMONTH, HOURLY_AVES_ALL.MEASDAY,
  HOURLY_AVES_ALL.MEASHOUR

试图将数据复制到另一个表而不是视图中,会引发相同的未知错误,即:

INSERT INTO HOURLY_AVES_SORTED 
(MEASYEAR,MEASMONTH,MEASDAY,MEASHOUR,GH,GK,GDH,TA)

SELECT 
HOURLY_AVES_ALL.MEASYEAR, HOURLY_AVES_ALL.MEASMONTH, HOURLY_AVES_ALL.MEASDAY,
HOURLY_AVES_ALL.MEASHOUR, /*HOURLY_AVES.MEASMIN, HOURLY_AVES_ALL.MEASSECOND, */
HOURLY_AVES_ALL.GH, HOURLY_AVES_ALL.GK, HOURLY_AVES_ALL.GDH, HOURLY_AVES_ALL.TA

FROM HOURLY_AVES

ORDER BY
(MEASYEAR, MEASMONTH, MEASDAY,MEASHOUR, GH, GK,GH, TA) 

非常欢迎任何提示,布赖恩

4

2 回答 2

2

Interbase 不支持视图语句中的ORDER BY子句。请参阅数据定义指南中SELECT的文档,第 8-4页(从书签“使用视图”->“创建视图”->“使用 SELECT 语句”中选择时会找到该页面)。

于 2012-11-14T20:32:11.210 回答
1

尝试使用列号:

CREATE VIEW HOURLY_AVES_SORT (MEASYEAR,MEASMONTH,MEASDAY,MEASHOUR,GH,GK,GDH,TA) as
SELECT
  h.MEASYEAR, h.MEASMONTH, h.MEASDAY, h.MEASHOUR, 
  h.GH, h.GK, h.GDH, h.TA

FROM 
  HOURLY_AVES h

ORDER BY
   1, 2, 3, 4
于 2012-11-14T18:32:49.577 回答