I am creating a view based on this table and I want to add a calculated column that will provide the result between the amount and the rate columns.
SELECT dbo.Invoices.Amount, dbo.Invoices.TransactionRate, dbo.Invoices.Amount * dbo.Invoices.TransactionRate AS Trans_Amt FROM dbo.Properties
The query and the creation of the Trans_Amt column works fine.
The problem is that the calculated column has too many decimal places and I do not know how to format the calculated column to show only 2 decimal places.
SELECT dbo.Invoices.Amount,
dbo.Invoices.TransactionRate,
CAST(dbo.Invoices.Amount * dbo.Invoices.TransactionRate AS DECIMAL(19,2)) AS Trans_Amt
FROM dbo.Properties
SELECT dbo.Invoices.Amount,
dbo.Invoices.TransactionRate,
CAST(dbo.Invoices.Amount * dbo.Invoices.TransactionRate AS DECIMAL(19,2)) AS Trans_Amt
FROM dbo.Properties
It worked like a charmed.
How can I display the result of the query in a 3,256.56 format
Here is an example - but many people on this forum (including yours truly) would advise and would prefer to do this type of formatting on the front-end - such as the client GUI or reporting services.
DECLARE @x FLOAT ;
SET @x = 232123445.73;
SELECT CONVERT(varchar(32),CAST(@x AS MONEY),1);