日期:2014-05-19  浏览次数:20633 次

在散30分!SQL问题哦!高手进来看看!不够+分顶这有分!
select   c.autoid,c.autobrand,c.autotype,avg(c.auto_price)   as   bj  
from  
(select   a.autoid,b.autobrand,b.autotype,a.auto_price   from   autoprice   a,autoinfo   b   where   a.autoid=b.autoid)   c  
where   c.auto_price   > 130-5   and   c.auto_price <130+5  
group   by   c.autoid,c.autobrand,c.autotype  
order   by   c.autobrand   desc,c.autotype   asc

也就是四舍五入的问题!改怎么加上这个条件呢!小弟SQL很菜的请高手帮忙
bj查询出来的
如果数据为112.6425   那么我想取112.6
如果数据为112.6525   那么我想取112.7

------解决方案--------------------
select c.autoid,c.autobrand,c.autotype, round(avg(c.auto_price),1) as bj
from
(select a.autoid,b.autobrand,b.autotype,a.auto_price from autoprice a,autoinfo b where a.autoid=b.autoid) c
where c.auto_price > 130-5 and c.auto_price <130+5
group by c.autoid,c.autobrand,c.autotype
order by c.autobrand desc,c.autotype asc

例如 SELECT ROUND(150.75, 1) 结果是150.8 请查看sql帮助里round函数

------解决方案--------------------
SELECT ROUND(150.75, 1)
30分也叫散啊。呵呵