Questions tagged [case]
In SQL, the CASE expression evaluates a list of conditions, returning the result for the first condition which evaluates to true. For programming languages' CASE questions, use the [switch-statement] tag instead.
8,216
questions
-3
votes
0
answers
10
views
Pc fans and power button not working when the motherboard works so I’ll have to turn on and of the system by the psu [closed]
I've tried to run the fans to make sure the case works but as you see nothing worked beside of the motherboards LED. I needed an adapter to plug the RGB controller to the motherboard and as I know you ...
0
votes
1
answer
29
views
How to vectorize a custom function to use with mutate() and case_when() in R?
I'm trying to run a custom function, QA2Char, to iterate down all the rows of a specific column in my dataframe and then append the output as a new column.
QA2Char takes a decimal/integer and outputs ...
0
votes
0
answers
10
views
How do I restart the timer when switching a case status back to In Progress after receiving the required information from the customer
A case is created with the status In Progress which starts the timer. Additional information is required from the customer and the status is set to Awaiting Info From Customer. This cancels the timer. ...
2
votes
4
answers
61
views
Creating new variable under dplyr based on similar values in many columns
I have a dataset where multiple individuals attended 6 events. Dataset looks somewhat as follows:
Series event_1 event_2 event_3 event_4 event_5 event_6
1 Bill Alicia Alicia ...
0
votes
2
answers
113
views
Row number, case and greater than in SQL [closed]
eff_date
jobname
Expected Rank
ID
Null
Consultant
2
100
31-07-2024
Advisor
1
100
14-03-2024
Trainer
1
101
05-02-2024
Trainer
2
101
Null
Security
1
102
01-03-2024
Security
2
102
06-12-2023
...
0
votes
1
answer
38
views
Dividing two float columns using absolute in a CASE statement returns a rounded value instead of raw value in Oracle
SELECT
CASE
WHEN ip.pricing_vol != 0
THEN ABS((ate.para_position / ip.pricing_vol))
ELSE 0
AS price,
ip.start_date, ip.end_date
FROM
...
0
votes
2
answers
50
views
Sum Case when statement using Condition 1 minus Condition 2
I have a table that contains product totals as well as a pre-calculated grand total
Type
Agent
Rev
Product 1
Agent 1
100
Product 2
Agent 1
90
Product 3
Agent 1
200
GrandTotal
Agent 1
390
I can ...
0
votes
1
answer
54
views
Struggling with mutate column/case_when "AND OR" statements
I am looking at resistance of urine infections to certain antibiotics.
The antibiotics I am looking at are nitrofurantoin (NIT), trimethoprim (TRI) and cefalexin (CLX).
I wanted to create two new ...
0
votes
2
answers
28
views
How to assign flag to a group of rows depending on a specific combination of values
I am trying to produce a case statement (if that's the best solution) that can help me capture the following:
ID
Codes
Flag
ID-001
C712
1
ID-001
W943
1
ID-001
W371
1
ID-002
C751
2
ID-002
C712
2
...
-1
votes
1
answer
40
views
How can I select a value from one dataframe based on two other values in another dataframe
From the following two dataframes, I want to substitute all data$code columns with the corresponding code$atc_code. To do this, the data$name value should correspond with code$med_name, and the data$...
0
votes
2
answers
38
views
In R create a new column from a column using the function case_when() with multiple conditional rules
I am trying to add a column. I have a column “Y” with values (numeric) going from -50 to 350, I would like to create a new column “Z” evaluating the values creating variables with the conditions from -...
1
vote
2
answers
54
views
Multiple case and conditions
I have two tables like this:
collection_id
added_on
edited_on
1
2024-06-19 20:16:41
null
2
2024-06-19 20:17:42
null
3
2024-06-19 20:17:57
null
and
detail_id
collection
detail_type
detail_value
...
-4
votes
2
answers
61
views
I am trying to run SQL statement getting the syntax error
Error code returned:
Result: near "Type": syntax error
At line 2:
SQL statement:
SELECT
InvoiceDate,
BillingAddress,
BillingCity,
total,
CASE
WHEN total < 2....
-2
votes
1
answer
51
views
Case condition to filter and SUM in Oracle
In case stmt, I have a condition where I need to sum total values excluding below 3 scenarios
if column has NULL
Column has "AGING"
OR IF IT HAS EMPTY STRING
Attaching snippet for same.
...
0
votes
1
answer
57
views
How to modify query run based on the day of the week?
I have code that runs every weekday looking for the previous day, however, on Mondays, it needs to look from last Friday through Sunday. Right now, I am manually commenting in and out rows of code if ...