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 2000 Forums
 SQL Server Development (2000)
 assing 0 if null while selecting max value

Author  Topic 

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2008-07-30 : 01:36:52
Hi
I am trying to select the maximum value of a field from a table but I want to assign 0 inst red of null if the table is empty I tried like this but not working
select max isnull(QuotationId,0) from InventoryPurchasequotationMaster

Thanks and Regards
Anu Palavila

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-07-30 : 01:38:50
[code]select @max int

select @max = max(QuotationId) from InventoryPurchasequotationMaster
select @max = isnull(@max, 0)[/code]



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-30 : 01:41:40
select @max = isnull(max(QuotationId),0) from InventoryPurchasequotationMaster
Go to Top of Page

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2008-07-30 : 03:54:14
Thanks for the answer

Thanks and Regards
Anu Palavila
Go to Top of Page

VGuyz
Posting Yak Master

121 Posts

Posted - 2008-07-30 : 03:56:55
Hi chk this,
select isnull(max(QuotationId),0) from InventoryPurchasequotationMaster
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-30 : 10:17:57
quote:
Originally posted by VGuyz

Hi chk this,
select isnull(max(QuotationId),0) from InventoryPurchasequotationMaster



how is this different what i suggested two hours ago?
Go to Top of Page
   

- Advertisement -