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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Query??

Author  Topic 

hirani_prashant
Yak Posting Veteran

93 Posts

Posted - 2008-06-05 : 06:54:30
Hi,

Is there any other way to write this query?

select product_code, 'Product_Type' = case Product_code when (Select min(Product_Code) from Products
where Product_Group_Code = 1) then 'All' else Product_Type End from products
where product_code in (select distinct isnull(product_code,0) from confirm_email_address
where trader_code = 200801)

-- Regards
Prashant Hirani

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-05 : 07:00:29
[code]select p.Product_code,
case when tmp2.MinCode IS NOT NULL then 'All'
else p.Product_Type
end
from products p
inner join (select distinct isnull(product_code,0) AS Code from confirm_email_address
where trader_code = 200801)tmp1
ON tmp1.Code=p.Product_code
left join (select min(Product_Code)AS MinCode from Products
where Product_Group_Code = 1) tmp2
on tmp2.MinCode=p.Product_code [/code]
Go to Top of Page
   

- Advertisement -