SQL SELECT 第一个和第四个数字

SQL SELECT first and 4th number

我在 table 中有 ISBN 号 9999-02-202-2 我需要检查第一个数字是否匹配第四个数字,如何使用 postgresql 中的 SELECT 来做到这一点?

使用 ANSI SQL:

select 
    case when substring('9999-02-202-2' from 1 for 1) = 
              substring('9999-02-202-2' from 4 for 1)
         then 1 else 0 end as matching_flag