Link to home
Start Free TrialLog in
Avatar of Tristan Shortland
Tristan ShortlandFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL Server data type problem when dividing then printing...

Hi,
I have the SQL statment below and the output is this:
24 / 115
0

I need the second number to be the result of the division - what am I doing wrong??

Thanks,
Tristan
--Calculate Conversion rate
		IF @CountUniqueVisits > 0 AND @CountPurchasers > 0
		BEGIN
			SET @ConversionRate = @CountPurchasers/@CountUniqueVisits
			PRINT CAST(@CountPurchasers AS VARCHAR) + ' / ' + CAST(@CountUniqueVisits AS VARCHAR)
			PRINT CONVERT(VARCHAR, @ConversionRate)
		END
 
OUTPUT:
24 / 115
0

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tristan Shortland

ASKER

That's done the trick.
Thank you!