Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: SQL
Expertise: Intermediate
Apr 26, 2017



Application Security Testing: An Integral Part of DevOps

Using Boolean Logic Instead of CASE WHEN

Once you get the hang of the CASE WHEN SQL Statement it can be easy to overuse it. Sometimes you do not need to even use the CASE WHEN Statement at all and you could simply replace it with Boolean logic. Now Boolean logic isn't a predefined topic per se, just an implementation. Take for example this CASE WHEN Statement:

FROM Pricelist_March
WHERE price    CASE PriceID
    WHEN 0 THEN 300
    WHEN 1 THEN 400
This can be replaced by the following:
FROM Pricelist_March
  PriceID = 0 AND price    PriceID = 1 AND price
Hannes du Preez
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date