Divide by Subquery returning 'Subquery returned more than 1 value.' error
问题 I have the following table in which I have two sales orders and each sales order has a different number of transactions. SaleOrder Transaction Amount S1 T1 20 S1 T2 20 S2 T1 15 S2 T2 15 S2 T3 15 The problem is I am getting the total sales order amount against each transaction in SQL Server table when in fact they need to be divided equally among the number of transactions like this: SaleOrder Transaction Amount S1 T1 10 S1 T2 10 S2 T1 5 S2 T2 5 S2 T3 5 I've written the following query: SELECT