So I have the following issue in creating a sql query. A linked server so am using an open query. (edit update: SQL Server) Two tables as per picture below: I need to insert value into a third table, the value to insert to the third table comes from the two tables above which I join via KEY ID. However,
Tag: sql
Drop partition if exists in HANA
I would like to know if there is a way to DROP a partition IF EXISTS in HANA. I have tried like below I am getting incorrect syntax error near IF What is the best available solution? Answer HANA does not support the IF EXISTS clause. You may want to work around this limitation by implementing your own “…
Query an AND in a many-to-many table
I know that this is a relatively simple question, I just can’t figure it out. I have three tables: people, presentations, and people_presentations. people and presentations both have ID columns, and people_presentations that has foreign keys to each of people and presentations. For example: people: pres…
how can I join multiple columns on two table in sql
I have two table like below how can I get all the information in table test_info and the name of the buyer AND the name of seller from the test_user table in the same statement? would just give me a seller or buyer but i would like to get the result for both Answer You must join 2 copies of
deleting all occurrences of a character before the next different character
In a postgres table I have a column with values like: I need to delete all 0 before the next character that is NOT a 0. So, the previous column will became: Is this possible in psql? Answer (No comment necessary.)
SQL: Increment ID only for new rows based on the count
Requirement: Generate new ID from the MAX ID for those Name doesn’t exist in the Target table and has count >1 Below is the Source data, The yellow highlighted are new rows, Those with count >1 are incremented with a new ID, and those with count =1 defaults to FM00000001 The expected result is hig…
psycopg2 takes a value as a column
I’m trying to create a table using psycopg2 and then insert outer data from some jsons. For this reason I defined 2 function: create_words_table() and insert_data(): So, attempting to execute them: I got further error: Looking at documentation, I don’t see any mistake applying simple INSERT query …
CASE Statement in WHERE Clause SQL Server
I’m having trouble sorting this out. I want to see the fiscal quarters for Date_Received. When the @ReviewPeriodQuarter = 1 then I want the Date_Received months 10,11,12. If @ReviewPeriodQuarter = 2 then I want the Date_Received months 1,2,3 etc. SQL Server doesn’t like the BETWEEN part of this. T…
Transform properties from JSON array into comma-separated string
I have a string column in an SQL-Server table on Azure which contains the following data: How can it be transformed into a comma-separated string containing “Jane, John”? Answer Here how to achieve this via a snippet of some of my older code, you should be able to loop through the table and do thi…
Converting sql data to json but json file include recordset
I’m trying to convert sql data to json data but when file is completed I get something ‘recordset’ what is this and how do i get rid of it. —–This is how I am getting the json .— Please tell me how i get rid of recordset, square brackets and output and rowsafftectd Answer W…