首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-02-27 
在散30分!SQL问题哦!高手进来看看!不够+分顶这有分!selectc.autoid,c.autobrand,c.autotype,avg(c.auto_pr

在散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分也叫散啊。呵呵

热点排行