Re: How can we make distinct of one particular column!

From: Lawrence Simela <lsimela_at_mahalini.prestel.co.uk>
Date: 1998/01/07
Message-ID: <68vbfl$65m$1_at_svr-c-02.core.theplanet.net>#1/1


Or you could use Reports 2.5.... or you could write your own little packaged function to help you along ...
something like :-
CREATE OR REPLACE PACKAGE Show_Once
AS
  col2_current table.col2%TYPE;

  FUNCTION f_col2( v_col2 IN table.col2%TYPE)   RETURN table.col2%TYPE;
  PRAGMA RESTRICT_REFERENCES(f_col2, WNDS); END; CREATE OR REPLACE PACKAGE BODY Show_Once AS
  FUNCTION f_col2( v_col2 IN table.col2%TYPE)   RETURN table.col2%TYPE
  IS
  BEGIN
    IF col2_current = v_col2 THEN

               RETURN NULL;
    ELSE

       col2_current  := v_col2 ;
       RETURN v_col2 ;

    END IF;
  END;
END; and then

SELECT col1, show_once.f_col2(col2), col3 FROM table
ORDER by col2;

Regards
Lawrence Simela
MAHALINI CONSULTING LIMITED Ian C. Sellers wrote in message <34B10B35.3CC09E15_at_boco.co.gov>...
>Tushar, I don't believe this will work. Group by requires either that
>you select with sum or group functions or group by every column you
>select.
>
>so this would work:
>
>SELECT COUNT(col1), col2, SUM(col3)
>FROM table
>GROUP BY col2
>
>but the example below will not.
>
>What you could do is to create a view with a select distinct to get only
>col2 and a key, then select from this view in the main statement.
>
>Good luck.
>-Ian
>
>JAYABH wrote:
>
>> If I have understood your question properly, I think what you
>> could do is
>> Select col1,col2,col3
>> from table
>> group by col2
>>
>> i.e you could use group by.
>> Thanks and Bye for now.
>> Tushar
>
>
>
Received on Wed Jan 07 1998 - 00:00:00 CET

Original text of this message