Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple newbie question

Status
Not open for further replies.

spiff2002

IS-IT--Management
Jan 31, 2003
40
I'm running a query on a MS SQL 2000 server and one of the fields has a lot of NULL values. I'm putting the output into a tab delimited file so the result has to be cleaned up before saving the file.
The following is the Query I'm using but I still cannot get rid of NULL values on the LAST_COST column. Is there a different way to do it???

Code:
select Distinct 
itemno,
DESCR ,
cast(bpcase as varchar(5))+'/'+bsize+'- '+measur as SIZE,
cast(PR2_PRICE as numeric)/100 as PRICE,
case LAST_COST
 when NULL then ''
 else LAST_COST end 
as LAST_COST

from dbo.itmprc 
inner join itmmas on PR2_ITEMNO=itemno 
inner join SLSHST on PR2_ITEMNO=hitmno
inner join cusmas on HCUSNO=cusmas.CUSNO 
left join dbo.LAST_COST on ITEM_NUMBER=PR2_ITEMNO
 
replace

Code:
case LAST_COST
 when NULL then ''
 else LAST_COST end

with

Code:
case LAST_COST
 when last_cost is NULL then ''
 else LAST_COST end

or

Code:
coalesce(last_cost,'')
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top