PDA

View Full Version : راهنمایی برای select مرکب



Mohsen82
دوشنبه 09 مرداد 1391, 14:04 عصر
سلام.
spزیر قراره مجموع select ها رو برام طبق فیلد Typeمرتب کنه و در قالب یک
جدول برگردونه. ولی فقط اولین select رو بر می گردونه.فکر کنم اشتباه نوشتم
اگر ممکنه راهنمایی بفرمایید.
ممنون.



CREARE proc [dbo].[select_ads
@date date
as
select top 14 percent * from tbl_Ads where tbl_Ads.[Type]=1 and Isactiv=1 and endDate > @date
select top 28 percent * from tbl_Ads where tbl_Ads.[Type]=2 and Isactiv=1 and endDate > @date
select top 43 percent * from tbl_Ads where tbl_Ads.[Type]=3 and Isactiv=1 and endDate > @date
select top 57 percent * from tbl_Ads where tbl_Ads.[Type]=4 and Isactiv=1 and endDate > @date
select top 71 percent * from tbl_Ads where tbl_Ads.[Type]=5 and Isactiv=1 and endDate > @date
select top 85 percent * from tbl_Ads where tbl_Ads.[Type]=6 and Isactiv=1 and endDate > @date
select top 100 percent * from tbl_Ads where tbl_Ads.[Type]=7 and Isactiv=1 and endDate > @date
order by [Type] desc

Arash_janusV3
سه شنبه 10 مرداد 1391, 02:24 صبح
بعد از هر selectی یک unionAll بگذارید به غیر از آخرین