Q
Q
Qairat2017-03-15 13:15:24
MySQL
Qairat, 2017-03-15 13:15:24

How to rewrite to MSSql?

Hello!
How to rewrite code in MySQL procedure to MsSQL?

IF(SUM(Plan) < SUM(Fact), 0, SUM(Fact)/SUM(Plan)*100) as Equipment

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Tsvetkov, 2017-03-15
@Qairat

IIF(SUM(Plan) < SUM(Fact), 0, SUM(Fact)/SUM(Plan)*100) as Equipment

D
d-stream, 2017-03-15
@d-stream

case when SUM(Plan) < SUM(Fact) then 0 else SUM(Fact)/SUM(Plan)*100 end

I would just write the other way around.
case when SUM(Plan) >= SUM(Fact) then SUM(Fact)/SUM(Plan)*100 else 0 end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question