Link to home
Start Free TrialLog in
Avatar of Zack
ZackFlag 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.
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

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
Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India 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 Zack

ASKER

Thank you that work my apologies for the delayed response.
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.