Skip to content
Advertisement

Tag: group-by

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

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

Advertisement