2012-12-03 45 views
-2

創建查詢以將下面的SELECT查詢組裝成一個查詢而不是每個查詢都有一些問題一個手動。這有助於自己一個創建CSV文件更容易和更快從dbo.XXXXX中選擇top n其中trade'in('a','b','c')

select top 200 * from dbo.abacus where type = 'A' 
select top 200 * from dbo.abacus where type = 'B' 
select top 200 * from dbo.abacus where type = 'E' 
select top 200 * from dbo.abacus where type = 'F' 
select top 200 * from dbo.abacus where type = 'F' 
select top 200 * from dbo.abacus where type = 'FX' 
select top 200 * from dbo.abacus where type = 'E' 

回答

0

嘗試UNION:從這裏

select top 200 * from dbo.abacus where type = 'A' 
union 
select top 200 * from dbo.abacus where type = 'B' 
union 
select top 200 * from dbo.abacus where type = 'E' 
union 
select top 200 * from dbo.abacus where type = 'F' 
union 
select top 200 * from dbo.abacus where type = 'F' 
union 
select top 200 * from dbo.abacus where type = 'FX' 
union 
select top 200 * from dbo.abacus where type = 'E' 
+0

乾杯,反正這個用做只是一個查詢,而不是所有選擇的聯合 – user1873160

+0

不是。如果你嘗試 「從dbo.abacus中選擇頂部200 *,其中輸入('A','B'...)」,甚至TOP 1400,但沒有什麼能保證你會得到200個。 –

+0

非常感謝。 :-) – user1873160

相關問題