select distinct on one column code example
Example 1: query DISTINCT
SELECT DISTINCT Column_name FROM table_name;
Example 2: select only distinct values another table
INSERT INTO Table2(Id) SELECT DISTINCT Id FROM Table1 WHERE Id NOT IN(SELECT Id FROM Table2);
Example 3: select distinct on 2 columns
SELECT agent_code, ord_amount, cust_code, ord_num
FROM orders
WHERE agent_code='A002';