选择我们的顺序 [英] select usinf order by

查看:115
本文介绍了选择我们的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要选择一个按2列排序的表,然后根据这种排序选择到第一行.

我写tis sql:

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 :

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;



我可以确定我选择a.tarih,a.adres_kod排序的第一行协定吗?

谢谢,



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

Thanks

推荐答案

,不幸的是,我在oracle工作.
oracle使用"where rownum"条件代替TOP.

如果我使用
unfortunately , I work at oracle .
instead of TOP , oracle use "where rownum" condition.

If I use
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 




此sql先执行"where条件",然后执行"order by",这不是我的需要.




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


这篇关于选择我们的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆