簡體   English   中英

oracle sql 查詢選擇偶數列

[英]oracle sql query for selecting Even number columns

在 oracle sql 中,當我試圖獲取 output 時,它會拋出錯誤。

select city,id from station where id % 2 = 0;

錯誤:

ORA-00911: invalid character
00911. 00000 -  "invalid character"
*Cause:    identifiers may not start with any ASCII character other than
           letters and numbers.  $#_ are also allowed after the first
           character.  Identifiers enclosed by doublequotes may contain
           any character other than a doublequote.  Alternative quotes
           (q'#...#') cannot use spaces, tabs, or carriage returns as
           delimiters.  For all other contexts, consult the SQL Language
           Reference Manual.

Oracle 不支持取模的%運算符。 您需要使用function mod()

select city,id from station where mod(id, 2) = 0;

DB Fiddle 上的演示

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM