Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Select in SQL server

Participant ,
Jul 31, 2008 Jul 31, 2008
Please someone explain this [ (CST.total_calls) IN (0, NULL) ] in plain English?
TOPICS
Database access
347
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 31, 2008 Jul 31, 2008
I think it could be if average is zero or null then the average is 0.... Thanks all
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 31, 2008 Jul 31, 2008
LATEST
emmim44 wrote:
> I think it could be if average is zero or null then the average is 0.... Thanks all

I suspect that is what the author intended. However, the statement might not return correct results. That expression is similar to saying:

WHEN AVG(CST.total_calls) = 0 OR AVG(CST.total_calls) = NULL

NULL is a special value. In most modern databases, null is never equal to anything. Not even itself. To detect null values you use the keywords "is null" instead of the equality operator "=".

WHEN AVG(CST.total_calls) = 0 OR AVG(CST.total_calls) IS NULL

There are also sql functions, like coalesce, that can automatically replace nulls with another value like 0 or an empty string, which can be useful in some cases.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources