case-when Questions

3

Solved

I have started to learn Ruby. I have a small project to build a game and tried to create a function that receives user input and handles it accordingly. def Game.listener print "> " while li...
Yarkand asked 29/11, 2016 at 14:43

5

Solved

On SQL server 2005 I am trying to query this select statement SELECT AlarmEventTransactionTableTable.TxnID, CASE AlarmEventTransactions.DeviceID WHEN DeviceID IN( '7', '10', '62', '58', '60', ...
Birdcage asked 18/5, 2011 at 9:49

3

Solved

I want to set the session_id automatically using the request_time parameter so i opted for a mysql stored procedure that contains a case statement.Here goes. create procedure upd_userinput(in requ...
Jebel asked 2/3, 2011 at 13:15

2

Solved

I want to put a conditional term after the ~ in a case_when function. My example: df: df <- structure(list(x = c("a", "a", "a", "b", "b", "...
Pacha asked 22/4, 2021 at 7:27

5

Solved

I have a playbook with multiple plays. Here is what it looks like: - name: Play A hosts: localhost roles: - do task to get either B or C - name: Play B hosts: Host B roles: - do necessary t...
Zampino asked 24/3, 2020 at 7:19

3

Solved

I am having some trouble getting mutate, across, and case_when to function properly, I've recreated a simple version of my problem here: a <- c(1:10) b <- c(2:11) c <- c(3:12) test <- ...
Lerner asked 17/1, 2021 at 0:32

2

Solved

I have a status_df with id and status at each stage: id stage status 15 1 Pending 15 2 Not Sent 16 1 Approved 16 2 Rejected 16 3 Not Sent 16 4 Not Sent 20 1 Approved 20 2 Appr...
Meloniemelony asked 3/2, 2021 at 23:59

0

I have a problem understanding how dplyr::case_when works. Here with this pretty simple line : library(tidyverse) case_when(TRUE ~ 50, FALSE ~ numeric(0)) I get numeric(0) while obviously, TRUE i...
Beneficence asked 28/1, 2021 at 17:22

11

Solved

The OR operator in the WHEN clause of a CASE statement is not supported. How can I do this? CASE ebv.db_no WHEN 22978 OR 23218 OR 23219 THEN 'WECS 9500' ELSE 'WECS 9520' END as wecs_system ...
Mischief asked 30/3, 2011 at 14:45

1

Solved

I am trying to use dplyr::case_when within dplyr::mutate to replace some values: data<-data%>% mutate(floor = case_when( floor_id == 2 ~ "ground_floor", floor_id == 3 ~ "mezzanine", floo...
Rafaellle asked 31/5, 2020 at 5:46

5

Solved

Getting error ORA-00932: inconsistent datatypes: expected CHAR got NUMBER 00932. 00000 - "inconsistent datatypes: expected %s got %s" When i run the following query SELECT distinct CASE when t...
Flatling asked 31/10, 2014 at 15:54

4

I want to run this query by using Doctrine in Symfony 2.3. But it seems like Doctrine does not understand CASE statement. Can anyone help? Thank you in advance! SELECT max(id) id, name FROM cards ...
Dwain asked 10/12, 2013 at 7:51

2

Solved

I've my T-SQL code below which I've converted in Pyspark but is giving me error CASE WHEN time_on_site.eventaction = 'IN' AND time_on_site.next_action = 'OUT' AND time_on_site.timespent_sec < 7...
Singular asked 21/2, 2019 at 21:59

4

Solved

I have a huge query which uses case/when often. Now I have this SQL here, which does not work. (select case when xyz.something = 1 then 'SOMETEXT' else (select case when xyz.somethingelse = 1...
Herold asked 27/7, 2010 at 9:40

1

Solved

I'm trying to create a new variable that populates with a 1 (true), 0 (false) in MySQL based on a series of dates and ladder levels (null-E). See fiddle: http://sqlfiddle.com/#!9/9975e1 Where th...
Lysenko asked 5/11, 2018 at 3:9

5

Solved

I have the dataframe of the following type df <- tibble::tribble(~x, c("A", "B"), c("A", "B", "C"), c("A", "B", "C", "D"), c("A", "B")) and vectors like these vec1 <- c("A", "B") vec2...
Bashaw asked 23/4, 2018 at 20:20

2

i want to write nested case when condition in query to store the value that will come from one case when condition and another case when condition into same new column.to get this kind of result i ...
Warp asked 24/11, 2016 at 5:11

4

Solved

I want to select a stored proc to execute based on user input. Something like - EXEC CASE @InputParam WHEN 'XML' THEN GetXMLData @ID, 'y' WHEN 'TABLE' THEN GetTableData @ID, 'y' END Can this ...
Cabala asked 13/4, 2012 at 15:27

5

Solved

Can the mutate be used when the mutation is conditional (depending on the values of certain column values)? This example helps showing what I mean. structure(list(a = c(1, 3, 4, 6, 3, 2, 5, 1), b...
Pulmotor asked 27/6, 2014 at 19:48

6

Solved

Let's say I have a data frame with several rows like the following: df <- data.frame(a = c(NA,20,NA), date1 = c("2016-03-01", "2016-02-01", "2016-02-01"), b = c(50,NA, NA), date2 = c("2016-0...
Obliterate asked 28/8, 2017 at 12:52

4

Solved

I have searched this site extensively but cannot find a solution. Here is the example of my query: SELECT ActivityID, Hours = (CASE WHEN ActivityTypeID <> 2 THEN FieldName = (Some Ag...
Expanse asked 15/1, 2010 at 15:34

2

Solved

I'm trying to write a query that puts some results (in my case a single result) at the top, and then sorts the rest. I have yet to find a PostgreSQL solution. Say I have a table called airports li...
Heaton asked 31/7, 2017 at 14:18

6

Solved

The problem statement is: Put the continents right... Oceania becomes Australasia Countries in Eurasia and Turkey go to Europe/Asia Caribbean islands starting with 'B' go to North America...
Clevie asked 12/5, 2015 at 15:41

3

Solved

I would like to have a query that uses the greater of two values/columns if a certain other value for the record is true. I'm trying to get a report account holdings. Unfortunately the DB usually ...
Manrope asked 30/9, 2015 at 19:51

1

Solved

This select is driving me crazy. The error is: Conversion error converting nvarchar value '17.30 h' to int data type. Data is: (DateTime) (Nvarchar) (DateTime) DATAINICI DATAMANUAL DATAFI nu...
Presser asked 27/5, 2015 at 10:38

© 2022 - 2024 — McMap. All rights reserved.