Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

select distinct postgres

-- NOTE: SELECT DISTINCT ON expressions must match initial ORDER BY expressions


SELECT
   DISTINCT ON (column1) column_alias,
   column2
FROM
   table_name
ORDER BY
   column1,
   column2;
Code language: SQL (Structured Query Language) (sql)

-- EXAMPLE
SELECT
   DISTINCT on (client_id) client_id, id
FROM
   public.dw_client_plan_histories
   where operation = 4
        and original_created_at >= '2022-06-17';
Source by www.postgresqltutorial.com #
 
PREVIOUS NEXT
Tagged: #select #distinct #postgres
ADD COMMENT
Topic
Name
5+8 =