divya

divya

  • NA
  • 186
  • 109.7k

union all with order by newid()???

May 30 2013 9:51 AM

Hai friends,
 
   here im getting error when im using union all and order by newid() together, can any one help me to solve this issue.. 

select distinct * from(select top 500 (A.AdId),A.AdImgPath,A.OnAdURL,A.AdSize from KZ_AdDetails A,KZ_Add_Cat Cat,KZ_Add_City Cit where  A.AddU_ID=Cat.AddU_ID and A.AddU_ID=Cit.AddU_ID and AdSize='250x250' order by newid()) X
union all
select distinct * from(select top 500 (A.AdId),A.AdImgPath,A.OnAdURL,A.AdSize from KZ_AdDetails A,KZ_Add_Cat Cat,KZ_Add_District Dis where  A.AddU_ID=Cat.AddU_ID and A.AddU_ID=Dis.AddU_ID and AdSize='250x250' order by newid()) Y

regards
Divya

Answers (9)