by Rafe
To select all columns in a table:
SELECT * FROM table_name;
To Select some specific columns:
SELECT c1, c2 FROM table_name;
To select unique values in column rows:
SELECT DISTINCT c1,c2 FROM table_name
To select columns c1 and c2 with a some conditions and ordered by an ascending format at column c1 and descending format at column c2:
SELECT c1, c2 FROM table_name
WHERE condition1 AND condition2 OR Condition3
ORDER BY c1 ASC, c2 DESC
PS: We Also Have BETWEEN X AND Y
and LIKE '_XX%'
or ILIKE '_xx%'
for some extra conditions
To Group By a table based on a column and do some aggregate function on some other column, one could do:
SELECT c1,c3 AGG(c2) FROM table_name
GROUP BY c1,c3
GROUP BY