Looks like your SQL Server version is 2008 R2 and I believe IIF function was added in SQL 2012.
Change this line to use CASE statement instead, e.g.
round(sum(amount) / case when sum(weight) = 0 then null else sum(weight) end, 2) as KgRt
>Thanks
>
>SQLSERVER Version is
>
>SQL Server Configuration Manager
>Microsoft Corporation
>Version: 2009.0100.4000.00
>
>
>Microsoft SQL Server Management Studio 10.50.4000.0
>Microsoft Data Access Components (MDAC) 6.1.7601.17514
>Microsoft MSXML 3.0 6.0
>Microsoft Internet Explorer 8.0.7601.17514
>Microsoft .NET Framework 2.0.50727.5420
>Operating System 6.1.7601
>
>I am using your command in Management studio
>
>this line also does not work
>
round(sum(amount)/iif(sum(weight)=0, null, sum(weight))),2) as kgrt
>
>Msg 102, Level 15, State 1, Line 2
>Incorrect syntax near '='.
>Msg 156, Level 15, State 1, Line 9
>Incorrect syntax near the keyword 'as'.
>
>
>I am using sqlserver for VFP and PHP
If it's not broken, fix it until it is.
My Blog