当前位置: 代码迷 >> ASP.NET >> 在散30分!SQL有关问题哦!来看看!不够+分顶这有分
  详细解决方案

在散30分!SQL有关问题哦!来看看!不够+分顶这有分

热度:3441   发布时间:2013-02-26 00:00:00.0
在散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分也叫散啊。呵呵
  相关解决方案