I have one-to-many relation between tables user and tag: Users: id username ————– 1 Bob 2 Alice 3 Eve Tags: id user_id name ——————– 1 1 …
Tag: join
Need to filter all rows in postgres where records share a common id but any one fails to pass a subquery
I have a table in Postgres that looks something like this: The algorithm is if any single record has reversed = true or status = foo, all records with the same group_id should be filtered. If group_id is null, which is possible, I’d like to keep those records regardless of reversed or status The closest…
MAX() OVER PARTITION BY not working as intended
I’m having some issues when i try to obtain the MAX value of a field withing a set of records and i hope some of you can help me finding what am i doing wrong. I’m trying to get the ID of the item of the most expensive line, within an order. Given this query: I’m getting this results: Result…
How to shorten mysql join query to avoid manual typing of each row?
I have a table that gets new rows for eg. I’d add more than 100 features like phone_number, username to the processed_donors to this table very soon.IS it possible to simplify this json_object(****) so It’s not an evergrowing list? Some way to use pandas+python, select * etc? Answer I think you co…
Query to join DateTimestamp column with another Table with StartDate and EndDate
I have below table with 3 column. Lets say table1 with the following data Another table with 4 columns, lets say table2 with following data What I would like to achieve is check in Table2 for start_date and End_Date where typ_Id = 1 from Table1 where E_Date comes under in Table2 Start_Date and End_Date. for I…
Is there something wrong with this SQL query
I am new to SQL queries and trying to understand it a little better. Is this SQL query valid regarding the picture below The question I was given was: “For each book authored (or co-authored) by “…
How could I use case within join and union?
I have 2 tables: Matches Rounds Inserts My query: I would like to know what places a particular team achieved (should probably use HAVING m.matchwinner = ‘fnatic’) MatchID – Team – Place 1 – fnatic – 1st 3 – fnatic – 3rd 4 – fnatic – 3rd what places …
SQL query to display Count of records based in range from another table
I have two tables Range and Employee. Range table consists of columns (Available programs for that salary like platinum and silver etc). Employee table has columns https://i.stack.imgur.com/RKaXP.png I want to write a SQL query in such a way that it gets the count of employees who fall under the given salary …
mysql query – clash between not in and/or
I’m trying to get all my products , from A specific categories and without some products from those categories . i did this query: The problem is that i’m still getting products with the string ‘SPLA’ or ‘SA OLP’ – because the NOT IN clash with the categories How to s…
SQL Joining of Multiple Tables
SQL newbie here, I am trying to have the table print out the sum of the wages, make, and car model for all the people that own a particular make/model combination. As of right now, the table prints …