Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 1 to 5 of 5 total |
Set null value from count result to 0 in SQL select |
Sun, May 13 2018 4:52 AM | Permanent Link |
Mike | Hi,
I am using the following SQL statement as sub select. SELECT COUNT(OrderID) AS MyCount FROM Jobs WHERE OrderID=derid AND OrderlineID > 0 AND status<>6 GROUP BY OrderID How can I set the return value from count(orderid) to 0 when it is null? |
Sun, May 13 2018 5:37 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Mike
Is the problem that you get some rows with a null or (as I'm guessing) that you get no rows? Roy |
Sun, May 13 2018 5:43 AM | Permanent Link |
Mike | Hi Roy,
I get some rows with a null. The null value must be set to 0. |
Sun, May 13 2018 5:48 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Mike
Just looking at it again I think your problem will be solved if you just drop the GROUP BY clause. I'd also use COUNT(*) SELECT COUNT(*) AS MyCount FROM Jobs WHERE OrderID=derid AND OrderlineID > 0 AND status<>6 You are picking a single OrderID so the GROUP BY is essentially grouping everything there anyway and isn't needed Roy Lambert |
Sun, May 13 2018 5:57 AM | Permanent Link |
Mike | Thank you!
That seems to do the trick. |
This web page was last updated on Tuesday, May 14, 2024 at 07:14 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |