This is a web app written in Python to add and delete tasks. This is the add_tasks function: @app.route(“/add”, methods=[“GET”, “POST”]) @login_required def add(): …
PostgreSQL: sum of days in range
I have a table as follows: Table “public.fish_schedule” Column | Type | Collation | Nullable | Default ——–+————————+———–+—…
Data aggregation by sliding time periods
[Query and question edited and fixed thanks to comments from @Gordon Linoff and @shawnt00] I recently inherited a SQL query that calculates the number of some events in time windows of 30 days from a log database. It uses a CTE (Common Table Expression) to generate the 30 days ranges since ‘2019-01-01&#…
SQL: create global alias for nested SELECT to be used in another nested SELECT
Let’s assume I’ve got a database with two tables: people which contains person’s id and his/her birth year for each person and parents which contains the (parent_id, child_id) pairs to represent the relative relationships between people. To make the explanation easier let’s assume each…
SQL Server Database Error Conversion failed when converting the nvarchar value ‘ ‘ to data type int
I am running this in TOAD. Please forgive my ignorance, I am new to SQL. it ran once and gave me all of the data I was looking for but now when I execute this query, I keep getting Database Error ‘SQL Server Database Error Conversion failed when converting the nvarchar value ‘ ‘ to data type…
SQL Query for max value from subsets
I have a table bls_jobs with the following columns: city, state, occ_title, jobs_1000, and loc_quotient I am trying to retrieve the highest loc_quotient for each city (each city has several occ_titles, and each occ_title has a loc_quotient) Currently, I can use this query: Which does return what I’m loo…
WHERE clause is not filtering all specifications
I’m trying to make a query with different specifications in WHERE clause and some of them are being ignored. SELECT DISTINCT f.NameLawyer AS ‘Comisiona’, f.Bill As ‘Factura’, f.Amount AS ‘…
Merge tables in R and update rows where dates overlap
I hope this makes sense – it’s my first post here so I’m sorry if the question is badly formed. I have tables OldData and NewData: I need merge these tables as below. Where IDs match, dates overlap, and Priority is higher in NewData, I need to update the dates in OldData to reflect NewData. …
Indexing (x 4 OR y 5)
I am searching for an index to make the following quick: The query is a delete and reads: so it deletes all rows that do not match a few hundred criteria on t1 and t2. explain gives a sequential scan and rearranges the query: Can I create an index that will avoid that full scan? Thanks in advance! Answer Alth…
How to iterate over PostgreSQL jsonb array of objects and modify elements?
Given jsonb array and PostgreSQL 12: Need to convert it to: Is it possible somehow to iterate over jsonb array and downcase only “type” values? I tried: but it separates data and type pairs into separateelements. Answer You need an intermediate level of nesting to rebuild the objects before you ag…