获取消息8114,级别16,状态5,行3错误将数据类型varchar转换为float

时间:2017-12-12 16:31:31

标签: sql

Declare @a Decimal;
Declare @b Decimal;

Set @a = 100*(Select price From prices Where prodid = 'a4');
Set @b = 100+(Select cgst from taxes where prodid = 'a4')+(Select sgst from taxes where prodid = 'a4')+(Select cess from taxes where prodid = 'a4')

SELECT
    Round(@a/@b,2) as 'Price per Crtn(excl Taxes)',
    t.cgst+'%' as 'CGST(%)',
    t.cgst*ROUND(@a*0.01/@b,2) as 'CGST Per Crtn',
    t.sgst+'%' as 'SGST(%)',
    t.sgst*ROUND(@a*0.01/@b,2) as 'SGST Per Crtn',
    t.cess+'%' as 'CESS(%)',t.cess*ROUND(@a*0.01/@b,2) as 'CESS Per Crtn',
    r.price as 'Price per Crtn(incl Taxes)',
    '11' as 'Quantity',
    '11'*ROUND(@a/@b,2) as 'Total Price(excl Taxes)', 
    Round(r.price*'11',2) as 'Total Price(incl Taxes)' 
FROM  
    products p 
JOIN 
    prices r ON (r.prodid = p.prodid) 
JOIN
    taxes t ON (t.prodid = r.prodid) 
WHERE
    p.prodid = 'a4'

请帮我解决此错误,因为我正在尝试在DataGridview中填充上述查询的输出

1 个答案:

答案 0 :(得分:0)

谢谢@Lamak和@Raska 我找到了答案

CAST(t.cgst AS varchar)+'%'