sql - Merge two SELECT queries and display data in one table? -


following query displaying data 2 tables, working fine want merge result , display output in single table:

select      item_model, quantity      items_master       item_model = 'keyboard'   select     avg(rate) avg_rate,     sum(amount) total_amount      item_details      item_model = 'keyboard'  group      item_model 

what possible way of doing pretty new sql please guide me how this. in advance. using sql server 2012.

i took both of queries , compiled one. 1 of more ways it

select     m.item_model,    m.quantity,    d.avg_rate,    d.total_amount      (select item_model, avg(rate) avg_rate,sum(amount) total_amount      item_details      item_model= 'keyboard' group item_model) d      inner join      items_master m on m.item_model = d.item_model 

it show "keyboard" because aggregate inline query excludes others. moved item_master second position better performance


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -