Avatar of Zack
Zack
Flag for Australia asked on

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.
Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
Ryan Chong

8/22/2022 - Mon
Ryan Chong

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

ASKER CERTIFIED SOLUTION
Nitin Sontakke

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Zack

ASKER
Thank you that work my apologies for the delayed response.
Ryan Chong

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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy