• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home » Resolved: SQL Case Statement: Set the default value for an Case

Resolved: SQL Case Statement: Set the default value for an Case

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

this time I need an explanation for SQL. I have seen on the internet now nothing special and maybe I have a thinking error.
I have a case statement and now I want to ” filter ” it in different ways. Specifically I have a question, whether it is possible to provide rows directly with the “ELSE Value” of the case, without writing this itself?
The example is with the word “Pflaume”, this contains the letter ‘e’ and is therefore recognized by the ‘e’ case. But I want to assign the DEFAULT value ‘default’ to this case.
Thank you and have a nice day

Answer:

Since cases are tested in order, you can check for this case before the LIKE '%e%' case.
In general, order your cases in order of specificity — put the exceptions first, then the general cases.

If you have better answer, please add a comment about this, thank you!

mysql sql
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: Sort dataframe columns value by close it to another column

27/03/2023

Resolved: PostgreSQL resample 1 minute OHLCV candle data into 5 minute OHLCV candle data

27/03/2023

Resolved: How do I navigate a table without any easily accessible distinctions?

27/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.