Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: SQL question

Re: SQL question

From: Vladimir Begun <Vladimir.Begun_at_oracle.com>
Date: Wed, 29 Jan 2003 16:08:59 -0800
Message-ID: <F001.0053DFC5.20030129160859@fatcity.com>


Jared.Still_at_radisys.com wrote:

>>I can do a COUNT(DISTINCT ename || job), but that doesn't seem to be 

>
> elegant
>
>>way of doing it.

>
> elegant = simple, concise, easy to understand.
>
> Looks elegant to me.

Jared, it just looks that that...

CONCAT = || yet another function call, yet another piece of code, yet another byte of memory... If you have more than two columns? If some of those are numeric, date? If ename is Smith and job is Smith and both can be nullable? :) NVLs? NVL2s? I think this approach is only valid when one really understands what she/he is looking for. Could be good for FBI, CHECK constraints but it's very risky and resource consuming (depends, can be neglected) for queries.

It's better to write something that just looks ugly but works faster and reliably. Simple, fast, and covers all 'strange' cases:

SELECT COUNT(*)
   FROM (

        SELECT DISTINCT
               ename
             , job
          FROM emp
        )

/

Regards,

-- 
Vladimir Begun
The statements and opinions expressed here are my own and
do not necessarily represent those of Oracle Corporation.

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Vladimir Begun
  INET: Vladimir.Begun_at_oracle.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Wed Jan 29 2003 - 18:08:59 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US