0

I'm trying an 0, before every column in my sql

select TemporaryStock * '0,'+ cast( VAT as varchar(50)) from Market

i get error Msg 8114, Level 16, State 5, Line 1 Error converting data type varchar to float.

2 Answers2

1

You don't need to cast... you just need to move the decimal.

select TemporaryStock * (VAT * 0.01) from Market

If you want every value to be like 0.###### then you can use:

select TemporaryStock  * convert(decimal(38,37),'0.' + convert(varchar,VAT))
S3S
  • 24,809
  • 5
  • 26
  • 45
0

If you want to add '0' before the VAT then use CONCAT(args1, args2) method:

select CONCAT('0',VAT) from ExpressMarket;

Note: Both the arguments should be of string type.

Or else you can refer the following to know more about how to concatenate and aliasing it.

MySQL select with CONCAT condition

Community
  • 1
  • 1
PassionInfinite
  • 640
  • 4
  • 14