I am working on a mobile application which takes two inputs – Source Station Name and Destination Station Names. Upon receiving these two inputs, the application would then enlist the names of trains …
Tag: join
SQL Server : sum and multiplies on 2 tables
I need help to SUM and MULTIPLIES on join 2 tables: tb1 tb2 In tb1, I need to sum QTY and multiples SKU with PRICE without repeating same SKU (21135208, 21035621): Current query: My result is: Expected result is: Answer I believe that you could filter out duplicates by using a subquery like SELECT DISTINCT … FROM tb1, while leaving
Adding missing records from another columns in a different table
I have 2 tables : Table A: A | B | C | D qwe 4 2019 10 qwe 2 2020 5 qwe 5 2019 5 Table B : A | B 3 2019 4 2019 5 2019 6 2019 7 2019 8 2019 9 2019 10 2019 11 …
Duplication of results after selecting data from two tables with the same values
Good day! I’m having a problem in duplication of results when I’m selecting data from two tables with the same values. I have one data in my first table homepost with an ID of 2 and I have three data …
Query slow when use count(*) and inner join
My query is taking around 5 seconds to run. It returns almost 5000 records. If I remove the Select Count(*) …, it runs very fast, but I need this data. Is there a way to improve this query? Thanks Answer Indexes recommended by Gordon Linoff are a must-have. Another thing you could to is move the computation from an inlined
How to force postgres to return 0 even if there are no rows matching query, using coalesce, group by and join
I’ve been trying hopelessly to get the following SQL statement to return the query results and default to 0 if there are no rows matching the query. This is the intended result: vol | year ——…
Selecting all foreign rows for each row useing a N-N table
I have a N-N table, lets say as an example Teachers and Subjects: There is a Teacher table as follows: There is a Subject table as follows: And there is a TeacherTeachesSubject as follows: Only that each table has more than 10000 entries. I need to make a query which returns me something like this: What I am doing right
SQL to select records from multiple table using joins
I want a SQL select query for below scenario. I have 6 tables. 1) University Univ_id University_Name 2)College College_id College_Name Univ_id (FK) 3)Department Dept_id Dept_name College_id (FK) …
SQL join condition either A or B but not both A and B
I have sales data by years and quarters and for the last year I want to fill missing quarters with last available value. Say we have source table: +——+———+——-+——–+ | year | …
How to INNER JOIN only one row from second table
I have a issue joining only one row from the second table statement: SELECT ART.*, EAN.* FROM ART,EAN WHERE ART.ARTNR = ean.unit_artnr AND ean.typ = ‘LE4’; TABLE EAN has sometimes 2 …