Let’s say I have this type of dataset: row Num_A Num_B Num_C Reg_1 Reg_2 —— —– —– —– —– —– 1 9400 9500 9700 AAA CCC 2 9700 …
Tag: case
Scale CASE WHEN to retrieve non-holiday dates
I have table containing records with start and end dates, so I have to grab every record that started on a Friday, and if any Friday is a holiday, get Thursday, and if Friday and Thursday are holidays,…
Replace 0 in one field in case statement result that is stringing fields
I have a statement like the following: select distinct s.field1, s.field 2, Case when s.intfield3 = 2018 then (RTRIM(cast(s.intfield4 as char (2))) +’/1/’+ cast(s.intfield3 as char (4))) when c….
How to fix Nested CASE Syntax Error “Invalid Number of Arguments” in Oracle SQL
Im running a query in Oracle and am trying to create a new column that is defined by the nested CASE statement below. I get an error on the highlighted “Else” statement saying “Invalid Number of …
showing columns in a particular pattern in postgresql
i have written a query which returns a table showing monthly total working hours of each person in the company. so the result is: name*****jan************feb**********march ……… dec Tom 170:…
MS-Access Query to PostgreSQL View
I am converting a microsoft access query into a postgresql view. The query has obvious components that I have found reasonable answers to. However, I am still stuck on getting the final result: …
SQL Server case based off of another column
How could I go about using a case statement to set column final, based on column S? The objective is to use any record that has a final, and also include any records from column S only if S = ‘…
Can we write case statement without having else statement
I have this query: It is giving me o/p as Id A B NULL NULL NULL I don’t want to have NULL values in my output, I only want to compare in A and B, is it possible in case statement. Answer A case expression can only manipulate the value of an expression, not remove rows from the result. If
SQL CASE Statement for no data
I have a table that has process engines 1,2,3,4,5,6 with a running status. When one of the engines is down the record gets deleted from the table. Using a case statement I can display the first engine that is down but how do I go about displaying the engines if 2 or more engines are down. For e.g. how do
PostgreSQL, SELECT CASE COALESCE
I need to ‘name’ categories: mycat is a text column with possible values ‘0’ to ‘4’. That works OK, but I have some an error in my program which very rarely writes null (or ” as I can see in pgAdmin). In such cases I have to treat that ” the same as ‘0’. But I can’t get that! I