Postgresql conditionally include distinct in query
Is there way to modify a query such as:
select distinct col1, col2
from our_schema.our_table
where (id = '1001')
The goal is to easily activate/deactivate the distinct keyword.
Obviously, one could move it to a comment such as:
select col1, col2 -- distinct
from our_schema.our_table
where (id = '1001')
Is there any easy way to do this in Postgresql?
I've seen 'dynamic SQL' in Microsoft SSMS using TSQL language. Is there something like this for Postgresql? Or something even simpler?