SQl具有和舍入数据类型

时间:2019-03-19 15:34:00

标签: sql-server

我对我制作的这个程序很烂

Select FirstName|' '|LastName as Customer_Name ,sum(price) as SubTotal, 
sum(round(MaxPrice - MinPrice),2), (price + (MaxPrice - Minprice)) as Total 
from People join Customer_Owner 
on People.PeopleId = Customer_Owner.PeopleId  join Orders 
on People.PeopleId = Orders.CustomerId  join Order_Item 
on Orders.OrderId = Order_Item.OrderId  join Item 
on Order_Item.ItemId = Item.ItemId 
group by FirstName,LastName having city = 'Clinton' order by LastName;

输出应该看起来像这样,但是每当我运行我的代码时,它都会给我带来错误,同时也给我一个求和/舍入误差。

Customer Name                   Subtotal     Sales Tax  Total

Patricia Jones                  48.00        2.88       50.88     
Paul Jones                      19.70        1.18       20.88     
Tara Roswell                    4.49         0.27       4.76      
Simon Tara                      145.00       8.70       153.70    
Theodore Turner                 16.25        0.98       17.23   

2 个答案:

答案 0 :(得分:0)

似乎放错了括号?

更改

let x = <props extends string>(...p: props[]): x<props> => p.reduce((o, k) => (o[k] = k, o), {} as x<props>);

sum(round(MaxPrice - MinPrice),2),

答案 1 :(得分:0)

可以通过将数据类型转换为数字来解决以下问题

  

总和(舍入(cast(cast(MaxPrice-MinPrice)为数值(36,2)),(price +(MaxPrice-Minprice)))为总计

让我知道它是否不起作用