My requirement is to display country name, total number of invoices and their average amount. Moreover, I need to return only those countries where the average invoice amount is greater than the average invoice amount of all invoices. Query for Oracle Database Result: Austria 1 9500 Expected: Austria 2 4825 S…
Best way to merge two SQL queries into one query
I have two small SQL queries that I would like to merge to be a single query that I will eventually use in a stored procedure. I have tried a CASE and IF/ELSE but could not get it to work. Below is the code. What I want to achieve is have the first column ‘Count of Open Order Lines’ based
I need help writing a query that shows the amount of orders for each month of the year and also the cumulative amount each year
I am so close to answering this question, but can’t figure out the final bits. I am using the AdventureWorks2019 database. My code is: I cant figure out how to order the ‘over’ part of the query. I know it needs to be “rows between unbounded preceding and current row”, but becaus…
Cant update table wp_options for wordpress in mariadb
Im trying to update wp_options table with a new url and the command just wont work. UPDATE TABLE wp_options SET option_value = “http://34.66.147.230” WHERE option_name = “siteurl”…
Using Triggers in PGAdmin4 v5 to get the geom of a line being generated in QGIS
So I have a database of pipes that is visually coded in qgis. My goal is to add a trigger to PGAdmin4 v5 that uses ST_StartPoint() and ST_EndPoint() to get the end points of the polyline (the pipe) as it is being entered. Then, I was going use this geometry to grab the nearest structure (a point) and autocomp…
Search by json key in jsonb column PostgreSQL
I have a table with following structure (simplified): Sometable: id data 1 {“data”: [{“type”: {“code”: “S”}}, {“type”: {“code”: “aB&…
Calculating points from number of days worked in a week/month by each employee
I am trying to calculate the average points for employees for a period of a week (or calendar month if possible) from a range of records. I have a table: daily_schedule which has records like this I …
Oracle sql – get months id between two dates
I have date range eg. ‘2021-01-05’ and ‘2021-02-10’. Two months January and February. Need resaults: Answer You want to iterate through the months. This is done with a recursive query in SQL:
Expecting Number (Average Temperature) but Getting Null [closed]
I want to pull the average temperature of two stations, JFK and La Guardia, for June 2020, but I am getting Null. Here is my query: SELECT AVG(temp) AS avg_temp FROM bigquery-public-data.noaa_gsod….
How to only display current and valid data from 2 tables in sql
I have these two tables: Table imp_source: Table imp_update: I need to write a query to have this result: All values of imp_update The values of imp_source when there is no update for seq column of a product/class combination. Update 1: As you can see, the row in imp_source is not in result Because in imp_upd…