Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

COUNT(DISTINCT) on multiple columns?

DonbotNov 25 2009 — edited Nov 25 2009
Is there an easier way of doing a COUNT(DISTINCT...) on multiple items than converting them to strings and concatenating them?

i.e. if I have a table with column string1 as VARCHAR2(1000), number2 as NUMBER, and date3 as DATE, and I want a count on how many distinct combinations of the three exist, is there a better way than:
SELECT COUNT(DISTINCT string1 || TO_CHAR(number2) || TO_CHAR(date3, 'YYYYMMDD'))
-- Don
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 23 2009
Added on Nov 25 2009
3 comments
23,007 views