I'm new to MS SQL and am having trouble formatting a result to 2 decimal places. Hoping someone here could help please?
The current syntax is,
(cast(substring(Narrative,patindex('%BENCHMARK-%',Narrative) + 10,patindex('%/TAKEN-%',Narrative) - (patindex('%BENCHMARK-%',Narrative) + 10)) as decimal(17,2)) - cast(substring(Narrative,patindex('%TAKEN-%',Narrative) + 6,patindex('%/CXR-%',Narrative) - (patindex('%TAKEN-%',Narrative) + 6)) as decimal(17,2))) / cast(substring(Narrative,patindex('%BENCHMARK-%',Narrative) + 10,patindex('%/TAKEN-%',Narrative) - (patindex('%BENCHMARK-%',Narrative) + 10)) as decimal(17,2)) * '100' as SavingsPercent
The result comes out to 6 decimal places but I need it to just 2.
If you can help I'd be very grateful. Many thanks.
The current syntax is,
(cast(substring(Narrative,patindex('%BENCHMARK-%',Narrative) + 10,patindex('%/TAKEN-%',Narrative) - (patindex('%BENCHMARK-%',Narrative) + 10)) as decimal(17,2)) - cast(substring(Narrative,patindex('%TAKEN-%',Narrative) + 6,patindex('%/CXR-%',Narrative) - (patindex('%TAKEN-%',Narrative) + 6)) as decimal(17,2))) / cast(substring(Narrative,patindex('%BENCHMARK-%',Narrative) + 10,patindex('%/TAKEN-%',Narrative) - (patindex('%BENCHMARK-%',Narrative) + 10)) as decimal(17,2)) * '100' as SavingsPercent
The result comes out to 6 decimal places but I need it to just 2.
If you can help I'd be very grateful. Many thanks.