Skip to content

Tag: case

MariaDB Case statement

I have the following SQL-Code in a Mariadb-Database: (1) I need the following result: If Matrix=’AW’ => I need the field “FaktorAW” else => I need the field “FaktorGW” is it possible to formulate Statement (1) with a “case statement”? Answer Of course, thi…

show who resit and passed and what course was it?

i need help find who fail in exam & resit and pass the exam only, heres the code: heres the result: I need find like this: Answer Possibly using a query like below. this is using your query as input. Also we have assumed that it is not possible to have a student have (PASS, FAIL) for a student on

MySQL alternative way to `CASE` Statement

May I know, is there any alternative way or short way to write this case statement shown in the below: I tried using mysql built in funciton ifnull as below: ifnull(p.our_price,p.sales_price) But it doesn’t work for me. Answer You could stick with a CASE expression but use COALESCE to make it more succi…

SQL: use CASE with AS

I’m working on a long SQL request and I want to use CASE inside but I don’t know how to write it. My request looks like : I want to add something like : I tried to add this at the end but it didn’t work : My goal is to edit key along its value Answer You can do

SQL CASE WHEN won’t meet condition

This is a solution to one of the leetcode problem. It is asking me to output the second highest salary from the table and if there are no second highest salary then the output should be null. The above is my solution. I used case and when syntax but the problem is that even when the table only has 1