[Solved] Subquery in select not working in SQL Server

The subqueries you are using in your select statement should return single value for your query to run without error. The following query will run without any issue, but it won’t give you the result you are expecting. SELECT TOP 10 (SELECT g_name FROM vgsales$ x WHERE g_platform = ‘X360’ AND a.g_rank = x.g_rank) AS … Read more

[Solved] SQL or Subquery if possible without using functions

You should use group by and sum, but before that, you should create two subqueries according to n_txn_type_key and then compare: select txn_type_4.n_event_key, txn_type_4.tran_amount from ( select n_event_key, sum(n_transaction_amount) as tran_amount from TABLE_NAME where n_txn_type_key = 4 group by n_event_key ) txn_type_4 inner join ( select n_event_key, sum(n_transaction_amount) as tran_amount from TABLE_NAME where n_txn_type_key = … Read more