sql server - How to join SELECT queries -


i have 3 queries given below:

select sum(prod) production ,sum(rej) rejection  machinename='a' data  select sum(prod) production ,sum(rej) rejection  machinename='b' data   select sum(prod) production ,sum(rej) rejection  machinename='c' data 

and want join these queries single row output.

first of have incorrect syntax. should be

select .... .... .... 

if have 3 different source tables can use union single output in following:

select sum(prod) production ,sum(rej) rejection  data1  machinename='a'  union -- or can use union keep duplicates  select sum(prod) production ,sum(rej) rejection  data2  machinename='b'  union -- or can use union keep duplicates  select sum(prod) production ,sum(rej) rejection  data3  machinename='c'  

if have same source table in example use in

select sum(prod) production ,sum(rej) rejection  data3  machinename in ('a','b','c')  

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -