I want to update numerical columns of one table based on matching string columns from another table.i.e., I have a table (let’s say table1) with 100 records containing 5 string (or text) columns and 10 numerical columns. Now I have another table that has the same structure (columns) and 20 records. In t…
How to run SQL query with inside a javascript loop(map)?
what I’m trying to do is: loop through array of objects using map function run multiple SQL queries according to object append result of queries with object I’m looping through offers which is array of object.I get free_item and buy_item which are associated with offer.I am using knexjs for postgr…
PostgreSQL: aggregate records by time interval
I would like to generate reports of GPS capturing rate by travel modes. I have in a table modes the type of travel modes used by users. So for example, the following is the sample data for travel mode by user 10 for different trips. And then for each user and for each trip, user’s GPS traces are recorde…
In Oracle, Can you create a new table with the same groups if you use CTAS Query?
I use the query CTAS to create a new table, however, when CTAS has finished, other users can´t select the new table, but they had access to the old, Is it a way to pass all the users and groups to the …
MySQL Order By Date And Boolean Priority: Number To Date Weirdness
I have a table which I want to get sorted by date_created descending, but there is also a pinned column which if that is 1 the row should be at the top regardless of date. The query I’ve come up with, …
Left outer join is working with SQLite while is not with MySQL
I have a table with products, orders, prices, date of sell. I need to create a table with the sells for a product in a single day. I used sqlite and this code worked just fine: /* Groups order date &…
Skip rows if subquery returns multiple rows in Postgres
I want to update table prod_replay_out based on subquery results in Postgres. However, subquery returns multiple rows but I want to skip those rows and update table based on single rows return by subquery. I have referred link Subquery returns more than 1 row error but max() function will not apply for my exp…
count number of times a value appears in a column not GROUP BY in SQL
Let us assume one has the following table (without the CountX column) : I would like to add the column ‘CountX’ with the number of different entries, per each combination of Name & City. I tried to use ROW_NUMBER() but it does not work well: I also tried to do a sub-query, using select distinc…
Is there a way to have SQL SELECT a column with a different date?
I’m trying to pull a pretty simple report that reviews the last day’s data. It looks similar to this: SELECT Name, Date, Count FROM dbo.X WHERE Date BETWEEN DATEADD(DD, -1, GETDATE()) AND DATEADD(DD, …
sqlite query python
i want to perform the below query SELECT t1.patient_report, COUNT(*) AS cnt, t1.doctor_report, (SELECT t2.doctor_report FROM infoTable t2 WHERE t2.patient_report = t1.patient_report AND cnt > 1 …