Oracle PL / SQL查询顺序问题与Distinct有关
发布时间:2020-12-12 13:06:18 所属栏目:百科 来源:网络整理
导读:有谁知道这个查询有什么问题? SELECT DISTINCT c.CN as ClaimNumber,a.ItemDate as BillReceivedDate,c.DTN as DocTrackNumber FROM ItemData a,ItemDataPage b,KeyGroupData c WHERE a.ItemTypeNum in (112,113,116,172,189) AND a.ItemNum = b.ItemNum AN
有谁知道这个查询有什么问题?
SELECT DISTINCT c.CN as ClaimNumber,a.ItemDate as BillReceivedDate,c.DTN as DocTrackNumber FROM ItemData a,ItemDataPage b,KeyGroupData c WHERE a.ItemTypeNum in (112,113,116,172,189) AND a.ItemNum = b.ItemNum AND b.ItemNum = c.ItemNum ORDER BY a.DateStored DESC; 我在职业生涯的大部分时间都做过T-Sql,这对我来说是正确的,但是这个查询是针对Oracle数据库而Toad只是将光标放在Order By部分的a.DateStored上.我确信这对于任何做PL / SQL的人都是基本的. 谢谢! [编辑]为了将来参考,SQL * Plus给出的错误是:“ORA-01791:不是SELECTed表达式” 您需要修改查询:SELECT DISTINCT c.CN as ClaimNumber,c.DTN as DocTrackNumber,a.DateStored FROM ItemData a,189) AND a.ItemNum = b.ItemNum AND b.ItemNum = c.ItemNum ORDER BY a.DateStored DESC; 在执行DISTINCT时,您的订单需要是所选列之一. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |