Discussions

EJB programming & troubleshooting: EJB-finder method using DISTINCT

  1. EJB-finder method using DISTINCT (2 messages)

    Hi!

    I want to write the following SQL in EJB-QL:

    SELECT DISTINCT column1, column2
    FROM `TABLE_NAME`

    In other words, all the returned values in column1 should be distinct, but not in column2.

    Thank you in advance!
  2. 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.
  3. EJB-finder method using DISTINCT[ Go to top ]

    You can achieve the distinct values in each column by using group by clause..but that is expensive operation(performance wise)
    -Mohit