sql - How to make a DISTINCT CONCAT statement? -
new sql developer here, how make distinct
concat
statement?
here statement without distinct
key:
column employee format a25; select concat(concat(employeefname, ' '), employeelname) "employee", jobtitle "job title" employee order employeefname;
here it's output:
employee job title ------------------------- ------------------------- bill murray cable installer bill murray cable installer bob smith project manager bob smith project manager frank herbert network specilist henry jones technical support homer simpson programmer jane doe programmer jane doe programmer jane doe programmer jane fonda project manager john jameson cable installer john jameson cable installer john carpenter technical support john carpenter technical support john jameson cable installer john carpenter technical support john carpenter technical support kathy smith network specilist mary jane project manager mary jane project manager 21 rows selected
if use distinct
key should have 11 rows selected, if use select distinct concat
error.
one option use group by
:
select concat(concat(employeefname, ' '), employeelname) "employee", jobtitle "job title" employee group concat(concat(employeefname, ' '), employeelname), jobtitle order "employee"
another option, if want use distinct
, subquery current query:
select distinct t.employee, t."job title" ( select concat(concat(employeefname, ' '), employeelname) "employee", jobtitle "job title" employee ) t
Comments
Post a Comment