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
 General SQL Server Forums
 New to SQL Server Programming
 Select Statement Question

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2011-10-06 : 16:23:53
I have the following Select Statement:


SELECT dbo.GLSParentItems.comp_item_no, dbo.bmprdstr_sql.item_no, dbo.GLSParentItems.qty_per_par, dbo.bmprdstr_sql.qty_per_par AS SubQty,dbo.GLSParentItems.item_no AS SubPart,
dbo.GLSParentItems.qty_per_par * dbo.bmprdstr_sql.qty_per_par AS GLSQty
FROM dbo.GLSParentItems LEFT OUTER JOIN
dbo.bmprdstr_sql ON dbo.GLSParentItems.item_no = dbo.bmprdstr_sql.comp_item_no


What I would like to do is if bmprdstr_sql.item_no is null then make it the same as dbo.GLSParentItems.item_no AS SubPart

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-10-06 : 16:29:59
Use COALESCE function for that.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-07 : 01:30:22
i hope GLSParentItems.item_no ,dbo.bmprdstr_sql.comp_item_no are of compatible data types

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -