oracle的复杂sql语句复习

来源:互联网 发布:java reactor模式 编辑:程序博客网 时间:2024/05/18 14:11

oracle的sql语句:

加了order by 后的distinct语句,需限制a.realvalue,a.synctime,因为这两个值有多值

select distinct a.id, a.title as title,b.smallpic as smallpic,min(a.realvalue),min(a.synctime)
from compositor a,article b,productcategory c
where a.id = b.id and a.compositortype='Visit' and a.datetype= 'Month'   and a.columnid = c.id
group by a.id, a.title ,b.smallpic
order by min(a.realvalue),min(a.synctime) 

max(a.realvalue) 是a.realvalue中的最大值,

mina.realvalue) 是a.realvalue中的最小值,

order by 某些字段,必须要在select里选有,否则报错.