I have below requirement in Impala, can someone please help me on this. if table1.column1 is null or empty string ,then table1.column2 else concat(table1.column1,” “,table1.column2) as address Answer Try this
Tag: sql
Combine 2 similar update queries into one query
Is there a way by which I can combine the above two queries (updating the same table) into one single query? Answer You may use a case expression to achieve this eg.
Is there way I can SELECT and JOIN COUNT different queries?
I’m using MYSQL and I have a message table like below. id parent_id sender_id receiver_id content readed sender_deleted receiver_deleted created 18 0 6 1 testab 0 0 0 2021-10-28 01:13:42 19 18 6 1 testcd 0 0 0 2021-10-28 01:14:55 I’m trying to combine two queries in one. Selecting and count where …
Alternative to CASE Statement to Compare and Summarize Data
I have a database that looks like the following; I need to compare the values from each price column and count the matched and mismatched prices and summarize as follows: Required Results I can do this via multiple case statements (below) but I’m wondering if there is a better approach. Current Code: An…
How to turn 5 sets of data from one column into 5 different columns
My current table looks like this CPNT_ID Org_Id Stud ID Compl_Dte Trainee Org001 101010 Nov 13, 2016 SvcTech Org001 101010 Nov 13, 2016 CrewChief Org001 101010 Nov 13, 2016 Trainee Org001 101013 Nov 13, 2016 SvcTech Org001 101013 Nov 13, 2016 Trainee Org002 101011 Nov 13, 2016 SvcTech Org002 101011 Nov 13, 20…
constraint c for table t does not exist on PostgreSQL even though it’s there
I’m trying to run an INSERT query on TablePlus. Instead of the query sending a success message, I’m getting an ERROR: constraint “minutes_clone_stick_tickers_unique” for table “minutes_clone” does not exist. Here is an image of my table structure. to replicate: I’ve t…
Why doesn’t SQLite appear to lock my table / row?
I’m tinkering with an in-memory sqlite database, trying to wrap my head around concurrency. Here’s an example using SQLAlchemy OUTPUT Here, I use two connections to write data to the same record. I would expect the output to be “A112”, because I thought the first connection would have …
Select only the most recent records by record ID
I have an access database, in it, I have a number of records where I need to pull just the latest information . Here’s the code I am trying to get working : The idea here, is I need 1 Training, and I need just the employees who took that training, and only the last time they took it. Currently
Calling a native function within a UDF in bigquery
I am trying to convert our legacy functions into standard SQL and so by using UDFs as a gig to reuse the old function names with the native functions. Here I have my UDF to_char and inside use the parameters to run FORMAT_DATE but when I execute it even though a routine is created I get errors with no additio…
Return active vs inactive records count against a given date in a single column
I currently have the following UsersData table which gives aggregated historical data at a given particular date: Date UserID Name isActive 2021-10-01 1 Sam 1 2021-10-01 2 Dan 1 2021-10-08 1 Sam 0 2021-10-08 2 Dan 1 Requirement My requirement is to create another aggregated data which will show active vs inac…