An alternative of DISTINCT
Ora_bieJan 29 2010 — edited Jan 29 2010Hi Fellows,
I am in search of an alternative of DISTINCT keyword to improve the performance of my queries, and in that I need your help. While in this research I used ROWID to replace DISTINCT. But my query ,having ROWID, is not returning all the valid enteries. I do not know where exactly I'm going wrong.
/***********************************************************************************************************************************
--1.
SELECT DISTINCT tk.tadf_key FROM tasks tk WHERE tk.area_cd = 'MEPP';
--2.
SELECT t.tadf_key FROM tasks t WHERE rowid in (select min(rowid) from tasks tas where tas.tadf_key=t.tadf_key) and t.area_cd = 'MEPP';
***********************************************************************************************************************************/
In my DB, through first query I'm getting 24 rows, but with second query I am loosing some and getting 18 rows.
Could you help me out in finding the perfect query to get rid of DISTINCT and to increase the performance.
Thanks in advance,
Harbinder