I have below tables.
create table html_details(A int,b int,c int,d nvarchar(4))
create table pdf_details(A int,b int,c int,d nvarchar(4))
insert into pdf_details values(1,2,3,'pdf')
insert into pdf_details values(1,2,3,'pdf')
insert into pdf_details values(4,5,6,'pdf')
insert into html_details values(1,2,3,'html')
insert into html_details values(1,2,3,'html')
insert into html_details values(4,5,6,'html')
now i am using below query to avoid duplication in each tables.
select distinct a,b,c,d from html_details
union all
select distinct a,b,c,d from pdf_details
but above query gives poor performance because of distinct function in both query.so i am using distinct in outer query.Now performance is improved, but will it give same output?Both query are same in logic?
select distinct a,b,c,d from (
select a,b,c,d from html_details
union all
select a,b,c,d from pdf_details
)a