My data is in a SQL table in the following format (I have about 20 different answers per user_id): I would like to create a view in PostgreSQL where all the data is shown according to User ID Thank you! Answer It is great example of not relational data (the semantic depends on row number), although the data a…
Nested SQL.promise() callback in Javascript
I want to write a nested callback JavaScript in order to use the subsequent ID’s of the INSERT statements in the different SQL tables. My code looks as follows: However, when trying to run this with Node.js it says Error: Callback function is not available with promise clients. Do you have a solution to…
SQL increment counter that resets on zero – Optimization?
I have a table that contains consecutive dates and integers. My goal is to add a counter that increments as each integer is zero and resets back to 1 if the integer is non-zero. I’m hoping that this …
INSERT + SELECT data type mismatch on similar fields
I’m running the following SQLite workaround to add a primary key to a table that did not have one. I am getting a datatype mismatch on However, the fields have exactly the same type. Is it possible that his happens due to running the queries from DbBrowser for SQLite? Answer You have defined the column …
Simple sql script fails on execution
Below is a sample bash script and it seems to error out when i execute the bash. The sql works on its own but in a script oddly. Please advise JOB_RUNNING=’SELECT count(1) from gv b,gv a WHERE b.paddr = a.addr AND type=”’USER”’ AND b.status=”’ACTIVE”’ AND …
select rows with same ID but different value in another column between two tables
i have to similar tables table 1 and table 2 .I want to compare the 2 tables and show the rows that ID is the same but has a different value in another column. table 1 ID ACTIVE 100 1 221 1 341 1 and table 2 ID ACTIVE 100 1 221 0 341 1 the output should be like
generate date range between min and max dates Athena presto SQL sequence error
I’m attempting to generate a series of dates in Presto SQL (Athena) using unnest and sequence something similair to generate_series in postgres. my table looks like I’m aiming for an output as follows I’ve attempted to use the following query to achieve this – however I get an error wh…
Query table with multiple “duplicates”, getting the most recent
I have a table which stores predictions from a machine learning model. This is a model that each hour (“predicted_at”) predicts a value for the next 24 hours(“predicted_for”). This means that the table have many different values for each “id” and “predicted_for”…
Get nvarchar records that were inserted as varchar
How can I get all values of an NVARCHAR column whose some of the values were accidently inserted without using the N prefix and so was replaced with ?, and then change those values into the correct form? For example, if I have the following: Output: I want to get what was originally ‘иытание2’ and…
join two sql table as column
i have two tables as below: firsttable id cat_id name 1 2 name_01 2 2 name_02 3 1 name_03 4 3 name_04 5 3 name_04 secondtable id name 1 cat_01 2 cat_02 3 cat_03 my question is how can i create below table result? id(secondtable) name(secondtable) count(firsttable) 1 cat_01 1 2 cat_02 2 3 cat_03 2 Answer