9,747 questions
-2
votes
1
answer
175
views
Updating a table with CASE
In this example I wanted to replace every NULL value in the Quantity column with the mean of the column. I'm using CASE here to achieve that but what ends up happening is instead of replacing NULL ...
1
vote
1
answer
93
views
Creating Materialized view in PG 17 ignores data types in SELECT
I have the following SQL to create a materialized view and the SQL seems reasonable to me but it's unclear from Postgres docs what should happen in this case.
I am listing the columns when creating ...
1
vote
1
answer
115
views
Avoid invalid cast inside CASE expression, in a query plan not respecting JOIN
I'm trying to get partitioned tables from a postgres DB. Our partitions have the date in them in various formats which I'm extracting like this
SELECT tab.relname AS table_name,
(CASE
...
0
votes
0
answers
38
views
LWC Quick Action Not Visible in Feed on Case Object
I have developed a Lightning Web Component (LWC) and exposed it as a Quick Action on the Case object. However, the action does not appear in the Feed section of the Case record page. Is it a ...
1
vote
1
answer
157
views
Issue with Cast in SQL Case expression - not working properly
I am using SQL Server 2017 and I am writing an UPDATE statement with a CASE expression. In the update statement I am having an issue with the calculation. It is a simple calculation when I cast the ...
0
votes
4
answers
187
views
Creating bash case patterns from a space-delimited string
I have a bash script that uses a space-delimited string to keep track of all the possible valid arguments:
FRUITS="apple orange pear banana cherry"
I use a bash case statement because some ...
4
votes
1
answer
123
views
Why do I get an "invalid identifier" error when I use LEFT()? [duplicate]
From a 6-character string in TERM_CODE_KEY I need to produce a calculated result as column academic_yr:
-- TERM_CODE_KEY is of type VARCHAR2(6) and returns values of the form YYYYMM
SELECT ...
0
votes
2
answers
159
views
Case expression to set a variable that is then used in another case expression [duplicate]
I have the following SQL query (VERY simplified):
SELECT
Column1,
Column2,
Column3,
Column4,
CASE
WHEN [Field1] = Condition1 THEN Value1
WHEN [Field1] = Condition2 ...
-1
votes
2
answers
79
views
SQL code for identifying salary for a status
I have 2 tables:
DEPT:
dept_no
C
N
1
200
100
2
300
150
3
400
200
and EMP:
dept_no
employee_no
Task_status
Salary
1
1
C
1
2
N
2
1
C
2
2
C
with column Salary has to be calculated. Task status is C is ...
4
votes
2
answers
138
views
How can I get R dplyr to report the number of rows that meet each case_when condition?
I'm often using dplyr case_when with several logical conditions. Because case_when evaluates sequentially, sometimes an earlier case applies and then is "taken off" the list even further ...
1
vote
1
answer
125
views
Extended condition of aggregating functions SQL
I need group speed by ram and return MAX(speed), where at least one NULL in speed values will return NULL.
ram
speed
128
600
128
600
128
750
128
750
128
800
128
900
32
400
32
NULL
32
500
64
450
64
500
...
-1
votes
1
answer
53
views
Replace or update values in a field that are incorrect
I have a table that looks like this:
id|week|start_date
1,4, 0026-10-23T00:00:00.000+00:00
2,5, 0026-09-22T00:00:00.000+00:00
3,6, 0026-09-25T00:00:00.000+00:00
I am trying to write a SQL statement ...
0
votes
1
answer
103
views
How can I use the COUNT and GROUP BY along with the CASE commands in SQLlite to show the number of students with each letter grade?
I am trying to use the SQL commands COUNT and GROUP BY to show the number of students with each letter grade, but I'm having difficulty in doing so. A new column that I created contains a letter grade ...
1
vote
2
answers
75
views
How do I check one column in R for a specific word and overwrite or return that word in another column? [closed]
Using R, I want to check the ManufShortName column and if there is the word 'BLANK', then I want to return the word 'BLANK' in another column named AnalysisNotesCode in the same row.
If there is a ...
-1
votes
1
answer
118
views
Is checking the requirements for ISNUMERIC() happening before evaluation of the CASE WHEN logic
Consider this
SELECT
CASE
WHEN 1=1 THEN 1
WHEN 1=1 THEN 1/0
END
This returns 1. A clear example of how the WHENs are evaluated in order.
However, when I do this:
DECLARE @...