In the above database, I want to calculate the value for “A2” using the other 3 variables. The premise is that each column has a specific score with respect to each variable and the javascript would sum the answers in a row with a null blank in the A2 slot in this case. Answer You can implement the same logic
Tag: case
Why am I getting a CASE error when in Data Studio?
I’m trying to convert a four-digit numerical code to a four-digit (one letter + 3 numbers) with a CASE clause in Data Studio. The four-digit numerical code is being pulled out of a Sheets file. I keep …
Replace and squeeze boolean feedback columns to single score column in BigQuery
I have data that looks like this (note one TRUE per row): I want to replace each TRUE with a number that depends on the column that it is in (5-1), so a score with very_good being 5 and very_poor being 1, and then squeeze it into one column. So it looks like this: So far I’ve tried this: But
Replacing case with IIF in SQL Server
So for my above query, I want to use IIF instead of CASE, because I want to show only uninsured patients, would something be correct? Because if I only use one case in my case scenario, the null will should up in my insurancestatus column instead of uninsured. Basically I just want the result for null showing up in result,
merge values in select
I have next part of query: SELECT types, count FROM … Result is next: types count soft 3 lite soft 2 middle soft 7 hard soft 2 other 5 what I need is to merge results …
How query two different Sum from the same table for the same column but with different condition?
I would like to fetch the sum of field TOTAL for active users and sum of field TOTAL for inactive users. Expecting is the query that results activeTotal = 15 and InactiveTotal = 50 SELECT SUM(actUser.total) as activeTotal, SUM(inActUser.total) as inactiveTotal FROM user actUser JOIN user inActUser ON inActUser.id = inActUser.id WHERE (actUser.active = 1 AND actUser.userId = 1) OR
How to order a query result by two columns with nulls last in one of the columns
I have the following table ‘client’ I want to fetch all rows from this table ordered by ID Desc, with nulls in the column filecount ordered last. So after the sorting I would like to get the following order: I tried the following but it doesn’t work: Answer I would use a CASE expression here: Demo
SQL Nested Joins (Case Statement and Join)
Hive DBMS; Two tables — A and B Table A Table B Question –> Trying to execute a query where: Join table A with table B, first on prnt_id, if it’s “unknown”, then join on sub_id, if that is “unknown”, join on ac_nm Desired Output: Answer You must use LEFT joins of TableB to 3 copies of TableA and filter
Evaluate Multiple conditions for same row
I have to compare 2 different sources and identify all the mismatches for all IDs Source_excel table Source_dw table Expected result I have tried the below query but it is giving only one mismatch. Actual output I understand that case expression will only check the first satisfying condition. Is there any other way I can check all the condition? Answer
SQL Server – Generate a column value which satisfy same condition in a day
I have a transaction table (Tran_Table) that contains Account Number, Transaction Date, Transaction Amount. I would like to generate a column that has “Yes” or “No” info in case if a transaction repeated in same day with same amount for same customer. Table and generated value example are shown below. how can i do this? Answer You can use window