Top "Case-when" questions

Use this tag only for SQL queries with case expressions.

OR is not supported with CASE Statement in SQL Server

The OR operator in the WHEN clause of a CASE statement is not supported. How can I do this? CASE …

sql sql-server tsql case case-when
Can dplyr package be used for conditional mutating?

Can the mutate be used when the mutation is conditional (depending on the values of certain column values)? This example …

r if-statement dplyr case-when mutate
SQL Server CASE .. WHEN .. IN statement

On SQL server 2005 I am trying to query this select statement SELECT AlarmEventTransactionTableTable.TxnID, CASE AlarmEventTransactions.DeviceID WHEN DeviceID IN( …

sql sql-server sql-server-2005 case-when
How do I use T-SQL's Case/When?

I have a huge query which uses case/when often. Now I have this SQL here, which does not work. (…

tsql case-when
How can I SELECT multiple columns within a CASE WHEN on SQL Server?

I have searched this site extensively but cannot find a solution. Here is the example of my query: SELECT ActivityID, …

sql-server select case-when
Oracle SQL CASE WHEN ORA-00932: inconsistent datatypes: expected CHAR got NUMBER 00932. 00000 - "inconsistent datatypes: expected %s got %s"

Getting error ORA-00932: inconsistent datatypes: expected CHAR got NUMBER 00932. 00000 - "inconsistent datatypes: expected %s got %s" When i run the …

sql oracle oracle-sqldeveloper case-when
How to using select with if condition in oracle?

My requirement is to get a number from a complex query and check if the num = desiredNum. If it is …

sql plsql case-when
Using CASE, WHEN, THEN, END in a select query with MySQL

I'm working on a baseball related website. I have a table with a batting lineup for two baseball teams: +----+…

mysql select subquery case-when
Oracle Case When Like

I have the following code: case when (a.je_source='Revaluation') then 'No_Location' when d.user_name like ('SCHE%…

oracle case-when
SQL - CASE WHEN count different values

I need to show how many different values every 'id' has. It should look like this: id | component_a | component_…

sql oracle count having case-when