I have the following table: and I want to check ALL values of the column ‘Token’ and return a flag string to designate what condition is met: when all records are in group (A, B) –> return ‘Condition1’, examples: when all records are in group (A, B, C) –> return ‘Condition2’ examples: so I am basically looking for a general
Tag: case
Recode column values in MySQL
I am dealing with a column named UCODE130 that has values anywhere from 1-130. I would like to replace the values with ranges. For example, I want to replace any 1, 2, 3, or 4 found in that column with a string “1 – 4” instead. I do not want to do just a select statement – I want to
SQL Order By on multiple columns containing Nulls
I have a table containing multiple columns, and I want to order by three of the columns within the table. I want to order by lot, then unit, and lastly number. Lot and Unit can contain nulls (need them listed at the bottom) whereas Number column does not contain Null. I’ve tried a bunch of case statements but its not
Case statement in multiple conditions?
I want to check the column mr.name, if mr.name is null then i have to replace mr.name as mr.ticket_no. How? Can use if else or case? When i use like this it will throw an error if mr.name = null means i have to replace mr.name = mr.ticket_no. I want to check the column mr.name, if mr.name is null then
SQLite: How to avoid using two CTE when using CASE statement?
I have a table trx with following schema: where id is the transaction id and p_id the id of the person doing it. I need to query trx so I get a table that allows me to plot an histogram of frequencies of transactions, that means, I want to know how many p_id did only 1 transaction, how many did
How to short a sql case query that uses between
Hi have this sql query: How can I short this query so I don’t use a lot of case statements? Answer You can try using mod subtracting the remainder t from you value by division for 1000 or as suggested by @DM you can also use the difference should be the same .. both involve function .. but there are
Syntax error for nested condtionals in SQL
I’m pretty new to redshift and I’ve been trying to to do a nested case when condition here, yet I get a syntax error ERROR: syntax error at or near “)” in this line of SQL: I’m not sure what’s wrong, since I’m familiar with Python and I’m pretty sure this is how nested conditions work Answer You should end
Arithmetic overflow error converting nvarchar to data type numeric in case query
I am trying to show the number of quotes won as a percentage of the total number of quotes in a time frame. For example. I have a total of 294 quotes and 173 of them are won. The result I am looking …
MySQL tree structure
Hello i am trying to prepare tree structure with MySql, tables look something like this. My Question is: Is it possible to do left join and sort columns by name, but if in lang is eq to “fra” return that row with that name, otherwise return “eng” name. Pseudo code So final result will be something like this, in total
Column merge using sum in case Oracle APEX
I need help How can I merge the column into a single column, here is my code, is this method is correct. I want to get the count of the selected row in the table for the columns. Can you guys help me I’m a beginner at SQL. Thank you in advance Answer If you want just one row in