oracle的复杂sql语句复习

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里选有,否则报错.

你可能感兴趣的:(oracle,sql,C++,c,Mina)