You are here: Re: help with parameter in WHERE « MsSQL Server « IT news, forums, messages
Re: help with parameter in WHERE

Posted by Hugo Kornelis on 03/21/07 20:03

On 21 Mar 2007 12:22:38 -0700, knowzero wrote:

>my query:
>select Product_List.*, Product_Sales.*
>from Product_List
>left outer join Product_Sales on Product_List.ID = Product_Sales.ID
>
>this works fine. its simple. I have this in a report and I would like
>to add a parameter @p1 to add to the query
>
>where Product_Sales.Order_Amount >= @p1
>
>my problem is that if @p1 is null I want to retrieve all recorders in
>Product_List. any ideas.

Hi knowzero,

WHERE Product_Sales.Order_Amount >= COALESCE(@p1,
Product_Sales.Order_Amount)

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация