GET HASH VALUE

GET HASH VALUE

 

  

I picked a table at random. I want a set of rows from the table, and
then select a random 2% of the rows from that set.

I have never used get_hash_value, nor OVER before. My thinking is that
hash_size could be the Number of rows in my set: (so I know how many 2%
is), then the <=2 is supposed to give me my 2%,

And to complicate matters I used the OVER partition in an effort to
eliminate duplicate rows. Since I was getting more than I needed, but
seemed to be close....

I know I'm not getting it...

select rowid, hash
from
(select rowid, dbms_utility.get_hash_value(dump(rowid),0,&&hash_size)
hash, rank()
over (partition by
dbms_utility.get_hash_value(dump(rowid),0,&&hash_size)
order by rowid) as SeqNumber
from logical_flights
where logical_flight_id = &&LFID
and dbms_utility.get_hash_value(dump(rowid),0,&&hash_size) <= 2)
where SeqNumber = 1;

Oracle LazyDBA home page