Oracle SQL WHEN condition in SELECT statement

I have the following select statement (example) which gives back a sum from a table. Select SUM(Salary) from Users d, MoreData m where d.Office = ‘A’ and m.Active = ‘Yes’ and d.id_user = m.id_of_user This works perfectly fine and adds up column salery for all users which are located in Office A abd are marked… Read More Oracle SQL WHEN condition in SELECT statement

If values in Column A are the same and other values are equal to, then put X in another column

I have something like this… FlightNum Class Seats SoldOut 10 A 0 10 B 5 10 C 15 10 D 25 I want to write a statement where FlightNum is the same, and A class has 0 seats, all rows for that FlightNum should put a "1" in the SoldOut column. FlightNum Class Seats SoldOut… Read More If values in Column A are the same and other values are equal to, then put X in another column

Interaction between import, class and match…case in Python

I’m puzzled by how from … import …, class constructor and match…case in Python interact between each other. Given there are two modules, foo and bar. foo imports CONST from bar and tries to use it in Foo class __init__() within match…case construction. This gives UnboundLocalError. The minimal reproducer is below. foo.py: from bar import… Read More Interaction between import, class and match…case in Python

Use case_when() in R with multiple conditional rules and multiple columns

I need to create a new column (insider_class) sorting data from a data.frame` based on specific rules using two columns as a reference. I have a column with several parameters (parameter) and another with values (value). The rule is: If value pH >=6 and <=9 then insider_class=yes, if not then insider_class=no If value DO >=… Read More Use case_when() in R with multiple conditional rules and multiple columns

how i can run case when with diferent nchar vector

I have this data frame. I need to substr fecha_nacimiento but it has 7 or 8 char. fecha_nacimiento n 1011997 1 31122002 2 i try this fecha_nacimiento <- fecha_nacimiento %>% mutate(year = case_when(nchar(fecha_nacimiento$fecha_nacimiento == 7 ~ substr(fecha_nacimiento, 4, 7))), nchar(fecha_nacimiento$fecha_nacimiento == 8 ~ substr(fecha_nacimiento, 5, 8))) But there is an error in MUTATE. I wish… Read More how i can run case when with diferent nchar vector