求助各路大神,简单查询与分组函数的结合!
select sum(sumtime),avg(hightime),t.id,t.name from t where t.date ='20130101'
查询这些信息,但是有分组函数,不能在一起查询, 有个问题就是能否结合,
有种解决办法
select (select sun(sumtime),.... from t where t.date = '20130101'),avg.... from t
where t.date = '20130101'
但是实际上我的条件非常多 不可能这样实现, 请问能在一条语句中实现么.
------解决方案--------------------SELECT sumtime ,
a.id ,
hightime
FROM ( SELECT SUM(sumtime) sumtime ,
ID
FROM t
GROUP BY id
) a
INNER JOIN ( SELECT AVG(hightime) hightime ,
ID
FROM t
GROUP BY id
) b ON a.id = b.id