0

I have a query similar to this

select to_char(
    select min(date) from MyTable, 
    'YYYY-MM-DD'
);

But I keep getting this error

ERROR:  syntax error at or near "select"
LINE 2:  select min(date) from MyTable, 
     ^
SQL state: 42601
Character: 18

1 Answer 1

2

Subqueries need their own parentheses:

select to_char( (select min(date) from MyTable), 'YYYY-MM-DD');

This would more traditionally be written as:

select to_char(min(date), 'YYYY-MM-DD')
from MyTable;

No subquery is necessary.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.