We help IT Professionals succeed at work.

SQL Rewrite without the NULLIF

Zack
Zack asked
on
104 Views
Last Modified: 2017-04-03
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.
Comment
Watch Question

CERTIFIED EXPERT

Commented:
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

Developer
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
ZackGeneral IT Goto Guy

Author

Commented:
Thank you that work my apologies for the delayed response.
CERTIFIED EXPERT

Commented:
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.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions