I want to select the top x value from a query where the average of valid values for a particular field is above 10. Why is this throwing an error? Answer Your code is throwing an error because avg() is an aggregation function and cannot be in the where clause. What you want seem to want is apply: The subquery
Tag: sql
JOIN multiple tables based on one reference table and count records
I have these following tables: cars: id manufacturer ——————– 1 Nissan 2 Toyota 3 Honda 4 Volkswagen type: id type car_id ————–…
Remove text after a codeword
I have a list of company names that have been sent with their added company numbers. How can I remove these company numbers (of different length) in SQL? “Limited” if in the name needs to be …
replace column with other column if value is ABC*
MYSQL PHPmyAdmin I have a table “photo” I have a column named “column_title” (varchar(300)) and a column named “column_description” (text). The title is sometimes ABC and …
Rolling sum based on date (when dates are missing)
You may be aware of rolling the results of an aggregate over a specific number of preceding rows. I.e.: how many hot dogs did I eat over the last 7 days SELECT HotDogCount, DateKey, …
select linked rows in the same table
I’m creating a branching dialog game, and used a dialog tool that outputs JSON with a link and a link_path to connect dialogs together. I’ve parsed and inserted this structure in PostgreSQL. I want to …
How do I use prepared statements with an OleDbDataAdapter?
I’m writing an API that will query a database given certain parameters. Some of those parameters will be supplied by the calling app (which should be trustworthy), but some of them will be supplied …
Finding the most active video maker within multiple tables(SQLite)
How can I find the initials of the most active video maker, the one that made the most videos considering the following tables using only one query? CREATE TABLE IF NOT EXISTS Videos ( title TEXT …
How to to create a new identifier in SQL for related addresses that have multiple relationships?
I have a data set like below that includes address and customer_id. In this example multiple customers can ship to the same address and a customer can ship to multiple addresses. I would like to use the relationships between these to create a new ID that joins all of the related addresses and customer_id̵…
Is it possible to use dynamic columns multiple times in a select?
I have some complex string replacement and I’m only permitted read-only access. I’d like to have several columns where each is dependent on the previous column so I can see if my substring and …