我有与此类似的查询
select to_char(
select min(date) from MyTable,
'YYYY-MM-DD'
);
但是我一直收到此错误
ERROR: syntax error at or near "select"
LINE 2: select min(date) from MyTable,
^
SQL state: 42601
Character: 18
答案 0 :(得分:2)
子查询需要自己的括号:
select to_char( (select min(date) from MyTable), 'YYYY-MM-DD');
更传统的说法是:
select to_char(min(date), 'YYYY-MM-DD')
from MyTable;
不需要子查询。