日期:2014-05-17 浏览次数:20476 次
select top 10 * from View_BrandInfo where brand_ispass=1 and brand_sort='0' and (brand_id in (select brand_id from BrandInfo
where not exists(select 1 from BrandInfo where brand_name=BrandInfo.brand_name and brand_class=BrandInfo.brand_class
and brand_id>BrandInfo.brand_id))) and (exists (select count(product_id) from ProductInfo where product_brand=brand_name
having count(product_id)>0) or exists (select count(scale_id) from ScaleInfo where scale_brandid=brand_name having count(scale_id)>0))
order by brand_id
SELECT TOP 10
*
FROM View_BrandInfo
WHERE brand_ispass = 1
AND brand_sort = '0'
AND ( brand_id IN (
SELECT brand_id
FROM BrandInfo
WHERE NOT EXISTS ( SELECT 1
FROM BrandInfo
WHERE brand_name = BrandInfo.brand_name
AND brand_class = BrandInfo.brand_class
AND brand_id > BrandInfo.brand_id ) ) )
AND ( EXISTS ( SELECT COUNT(product_id)
FROM ProductInfo
WHERE product_brand = View_BrandInfo.brand_name --添加上View_BrandInfo