Postgresql – Custom date range in SQL
I am trying to add a date range to my sql query. The date range should change every quarter Example on April 1 2024 - The date range for the data should be trailing 12 months, ie it should look…
I am trying to add a date range to my sql query. The date range should change every quarter Example on April 1 2024 - The date range for the data should be trailing 12 months, ie it should look…
I have a table orders in Postgres with columns offer_id and date. I need to write a query which fills in all null cases in column offer_id, using the previous not-null value. I tried to use the window function lag()…
My answer related to laravel I have table in mysql. I came across that some columns I didn't pass while inserting. how mysql accept inserting those records without throw exception? enter image description here those are the columns which added…
I need help optimize below postgresql query. Currently its taking more than 3 min to get the data , due to that my API got timeout ,can you please help me to get the result set within 59 seconds. Thanks…
I am building a data table with pagination on the frontend and the table contains advanced filtering and sorting with optional column visibility. There's also the possibility to do actions on the selected rows in the table. The data in…
For each row in table line there can be many rows in table line_version. I need to find only N (let's say 2) "latest" rows for each line row. Latest here means the largest IDs. For example, that's how line_version…
I have 2 tables: Events Attendance I wrote a function that gets triggered on every row insert or update in the Attendance table, to update "Event"."attendees_count" column by incrementing by +1 if it's an insert, decrement by -1 if attendance…
I have a MYSQL database with a table 'product', about 500 000 rows, with a column 'oem' (varchar 255, utf8_unicode_ci). I have another table 'oem' with a column 'oem' too (varchar 255, utf8_unicode_ci), about 150 000 rows. I need to…
Using Presto SQL, the original format of the column appears like this "{"ORDERS (completed)": 1000.00, "ORDERS (failed) USD": 3000.00}" and I am trying to extract the key and value by parsing and casting as map (varchar, double) and then unnesting…
I have 3 tables I am trying to query, with one table that links the other two. The tables are CITY, SITE, and ACTIVITIES. They contain sites within cities, and then separate activities at each site. Not every site has…