MYSQL subquery using distinct
I have a table cab name value 1 PHP 1 1 PHP 2 1 PHP 0 2 LHL 0 3 GHG 3 3 GHG 2 I am looking to get the distinct cab and name plus how many values =0…
I have a table cab name value 1 PHP 1 1 PHP 2 1 PHP 0 2 LHL 0 3 GHG 3 3 GHG 2 I am looking to get the distinct cab and name plus how many values =0…
SELECT u.id FROM user u WHERE u.id IN (7, 11) if I have no results for the ids specified, I want to return all users, similar to this query : SELECT u.id FROM user u the difficulty and I want…
How to calculate median for selling_eur in this table? id listing_id category amount original_eur selling_eur user_id rounds_id 0 10088 m1-1579cd77-6863-469d-8798-9e1bef199d2f Category 2 2 nan 350.11 eu-central-1:6fcfad76-ef06-4ea6-9e14-9fa4a5d62b8f 31 1 10089 m1-2adfde90-de27-4048-aa3e-bc7e76c03b0c Prime Seats 4 nan 962.81 eu-central-1:6fcfad76-ef06-4ea6-9e14-9fa4a5d62b8f 28 2 10090 m3-024c20ad-e21d-4bb3-966e-44c69e760b15…
I have two tables: Table Table I need to get info from table 1 and table 2 by id_banner (count of rows for equal id_banner is equal) For example, getting info for id_banner = 51 will post 3 different rows…
I am working with a database for an animal sanctuary where people can make donations to specific animals. I am trying to create a function that would return which animal a donor has donated to the most. The table I…
I have 3 UPDATE statements (that update more than one column) that I would like to execute against a list of id's without having to run the 3 update statements once by one against each id. Here are the 3…
I'm trying to select rows, where neither A nor B have an entry with more €: This is an example of my data Column A Column B € A B 100 B A 100 C B 80 B C 80…
I am still a novice to SQL, using PostgreSQL 16.2. create table users( user_id serial primary key ); create table task_pool( task_id serial primary key, order_id integer, clicker_id integer, INDEX idx_order_id (order_id) ); create table task_dispersal( id serial primary key,…
I have a simple order table in my postgres db and I want to join from a table of payments to create a new column for each order where the latest payment is indicated. Each payment row looks like this:…
I have a list of ids: select id from id where sid = 2403 The above simply returns a list of ids. e.g. id = 401434786, 401434787, 401434788, etc. When I run one of these ids in my tval table,…