Click here to Skip to main content
15,911,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to select a table with order by 2 column and than pick to first row according to this sort.

I write tis sql :

SQL
SELECT il_kod INTO v_il_kod FROM (SELECT a.il_kod
                       FROM m_m_adres a
                      WHERE a.hesap_no = p_hesap_no
                        AND a.adres_kod LIKE v_adres_kod_like
                        AND a.adres_ulke_kod = 169
                        AND a.il_kod IS NOT NULL
                        ORDER BY a.tarih,a.adres_kod ) where rownum <= 1;


can I be sure that I pick the first row accordint to a.tarih,a.adres_kod sort ?

Thanks
Posted

1 solution

unfortunately , I work at oracle .
instead of TOP , oracle use "where rownum" condition.

If I use
SQL
SELECT a.il_kod
                       FROM m_m_adres a
                      WHERE a.hesap_no = p_hesap_no
                        AND a.adres_kod LIKE v_adres_kod_like
                        AND a.adres_ulke_kod = 169
                        AND a.il_kod IS NOT NULL
                         where rownum <= 1 ORDER BY a.tarih,a.adres_kod 



this sql execute "where condition" firstly and then "order by" , and this is not my need .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900