sql查询中的疑问 [英] doubt in sql query
本文介绍了sql查询中的疑问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
创建表项目(item1浮点,item2浮点,结果为(item1 * item2))
插入项目值(145.45,154.25)
第三列的输出显示为22435.6625
但我的目标是结果显示得足够像22435.66一样
如何编写查询.
谢谢.
解决方案
使用ROUND函数.
SELECT ROUND(CAST(22435.6625 AS float), 2, 1)
SELECT CAST(22435.6625 AS NUMERIC(10, 2))
我认为这可能对您有帮助...:)
您好,
您的查询现在是正确的,您希望结果最多保留2个小数位,即22435.66,再好,您要做的就是在sql中使用round函数,使用以下查询,您将确保获得所需的输出
round给出的语法是
从table_name中选择SELECT ROUND(列名,小数)
其中列名是您想要的列名
小数表示:指定要返回的小数位数.
下面给出的是您的查询
select round(result,2) from items
一旦找到有用的答案,就对我的答案进行评分
谢谢&问候
基:rose:
hi
in my project i am need to multiply two columns. i am take table like
create table items(item1 float,item2 float, result as (item1 * item2))
insert into items values (145.45,154.25)
output display for 3rd column is 22435.6625
but my aim is result is disply like 22435.66 its enough
how to write a query.
Thanks.
解决方案
Use the ROUND function.
SELECT ROUND(CAST(22435.6625 AS float), 2, 1)
SELECT CAST(22435.6625 AS NUMERIC(10, 2))
I think this may help u... :)
hello,
You query is correct now u want the result upto 2 decimal places thats 22435.66 well ajay all u have to do is use the round function in sql use the following query and u will surelu get the required output
the syntax given for round is
SELECT ROUND(column_name,decimals) FROM table_name
where column name is the name of the column that u want
decimal means: Specifies the number of decimals to be returned.
given below is ur query
select round(result,2) from items
do rate my answer once you find it useful
Thanks & Regards
Radix :rose:
这篇关于sql查询中的疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文