Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Gopher
Yak Posting Veteran
83 Posts |
Posted - 2006-09-22 : 10:55:11
|
Hi AllI have a problem where I am making 2 select statements on the same table:select * from SectorSalesByPrdGroup where branch = '1100' and sectorcode <> 'Zt'order by prodgrp,sectorcodeselect * from SectorSalesByPrdGroup where branch = '1100' and sectorcode = 'Zt'order by prodgrp,sectorcodeI want the results of the second query with 'Zt' to appear at the bottom of the results. I tried using the Union syntax but it did not work.Any ideas???? |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-09-22 : 11:18:47
|
try this. the 2 query can be combine into 1.select *from SectorSalesByPrdGroup where branch = '1100'order by case when sectorcode <> 'Zt' then 0 else 1 end, prodgrp, sectorcode KH |
 |
|
Gopher
Yak Posting Veteran
83 Posts |
Posted - 2006-09-22 : 11:42:21
|
Thanks worked perfectly!quote: Originally posted by khtan try this. the 2 query can be combine into 1.select *from SectorSalesByPrdGroup where branch = '1100'order by case when sectorcode <> 'Zt' then 0 else 1 end, prodgrp, sectorcode KH
|
 |
|
|
|
|