SQL Rewrite without the NULLIF

Hi EE,

The 3rd party SQL interpreter I am running this script via doesn't like the NULLIF the script works fine when ran within SQL Server directly.

select NULLIF(count(*)*100, 0) as Number from vwReg_RMFeedback_Posted where IncidentInvolved = 'Complaint' 
and (select count(*) from tblDayDates where DayDate between IncidentDate and FBAckDate and DateName(WeekDay,DayDate) not in ('Saturday', 'Sunday')) <= 3
and FBAckDate is not null and Site Like '%Bay%'

Open in new window


Is there a way to rewrite this SQL script without the NULLIF?

Any assistance is welcome.

Thank you.
ZackGeneral IT Goto GuyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
based on your logic, you can try:

select count(*)*100 as Number 
from vwReg_RMFeedback_Posted 
where IncidentInvolved = 'Complaint' 
and (select count(*) from tblDayDates where DayDate between IncidentDate and FBAckDate and DateName(WeekDay,DayDate) not in ('Saturday', 'Sunday')) <= 3
and FBAckDate is not null and Site Like '%Bay%'

Open in new window

0
Nitin SontakkeDeveloperCommented:
Try changing select to the following, which is effectively the same:

select case when count(*)*100 = 0 then null else count(*)*100 end  as Number 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ZackGeneral IT Goto GuyAuthor Commented:
Thank you that work my apologies for the delayed response.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
technically that won't return a null for count(*) if there's record(s) returned, so you no need to compare it with case when if it met that condition.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.