I have a table with field bhk, size, price. i am using distinct to get unique by following query
1 Query
select distinct(bhk,size,perprice),bhk,size,price from project_units;
and i and also querying by
2 Query
select bhk, array_agg(size) as size from project_units where project_id = '12' and bhk is not null and not bhk = '1bhk' group by bhk
as a result i get
[
{
bhk:"1bhk",
size:{123,121,231}
},
{
bhk:"2bhk",
size:{223,321,131}
}
]
By 2 Query i also want to retrieve price also or there is any other way to get distinct on bhk size and price by 2 Query
distinctis not a function. It always applies to all columns in the select list. Enclosing one (or more) of the columns with parentheses won't change anything and is useless.distinct (a),bis the same asdistinct a,(b)ordistinct a,bdistinct (a,b),cis the same asdistinct row(a,b),c