I have 4 tables ProjectTable projectid: INT (pk) modifiedDate: DateTime2 … ProjectFinalizeTable id: INT (pk) projectid: INT (fk) modifiedDate: DateTime2 … ProjectAdditionalTimeTable id: INT (…
Tag: join
How can I override rows from another table?
I have two tables: TableA ID Name — —- 1 aaa 2 bbb 3 ccc 4 ddd TableB ID Name — ——– 3 WWXXYYZZ I want to select from both tables, but skip the rows which exist in TableB. The …
Full Join using a fuzzy join but with distinct matching
We have a table of expected payments and a table of payments made. We need to be able to match payments with a singular expected payment but we allow a +-3 day window for it to be made. On top of that, it should be a one-to-one match. So imagine I have a table of expected payments and payments The
How to query across multiple databases
I have a set of data that belongs to two different tables in two different databases. I have performed the query but I am getting a syntax error. The two databases are: This is what I am doing: Why would it give me an error on this part? as the syntax appears correct Any help is appreciated. Answer This Back.…
Extracting the id of the products missing from the third table with the specified value in SQL
I have 3 tables: products (id, category, …), store_offers (product_id, offer_id, platform) – joining the products table with many tables with offers, e.g. ebay, amazon, etc. ebay_offers (id, status, country, …). I need to get the id of products (in addition with a specific category_id) that …
Joining two select statements together with outer join
My query on SQL Server: select s.learners_id, s.cv_student_id, s.first_name + ‘ ‘ + s.last_name student_name, p.program_name, dc.fulldate program_start_date, sd.discount_value, dt….
How do I remove results based on conditions to calculate an average
I have the schema below. A quick explanation of it is: bob rated up 5/5 james rated up 1/5 macy rated up 5/5 The logic: If I am personA, look up everyone I have blocked. Look up all the movie …
How to replace table1 column value with table2 column value in MySQL select left join
Let’s say I have two MySQL tables: table1 (templates) Columns: id_template, name, col3, col4, … table2 (aliases) Columns: id_alias, id_template_orig, id_user, alias I want to select a row from the table1 (templates) including all the columns (*). In the same select statement I want to check if cur…
SQL: Joining tables and dividing each cell by match cell in another table?
Here is my population dataset detailing the population of each state through 2010 – 2019: Here is my consumer complaints dataset which has date received and state: I already have the complaints for each state per year: I know I need to join compltsbypear and uspop on state and divide 2011(from complaint…
SQL- Invalid query because of aggregate function with simple calculations for each date and ID
I very new to SQL (less than 100Hrs). Problem case is as mentioned below. Every time I try a query either get incorrect output or error that “not contained in either an aggregate function or the GROUP BY clause” Have tried searching similar questions or example but no results. I am lost now. Pleas…