I want to write the following SQL in EJB-QL:
SELECT DISTINCT column1, column2
In other words, all the returned values in column1 should be distinct, but not in column2.
Thank you in advance!
In SQL, DISTINCT applies to the whole result, not to separate columns. It simply means that with DISTINCT present, all duplicate rows will be ommited in the result.
Example: table T with rows (1,2), (1,2), (1,1). 'SELECT DISTINCT * T' then return (1,2), (1,1).
So this query won't give you the result you described.
You can achieve the distinct values in each column by using group by clause..but that is expensive operation(performance wise)