Question : if else statment in sybase

Hi,

I am trying to write an if - else statement where the table Machine has PROD and CPU columns.  I want to write it such that if PROD = 'Y' then insert the number of cpu in CPU column to another temporary table call #CpuCount, then sum up the number.  Can anyone please help me out ?  The table is in Sybase.  Thanks.

Answer : if else statment in sybase

Not sure where the IF would come in?

Assuming #cpuCount already exists and you want to include any data in there in your sum:

insert #cpuCount select CPU from Machine where PROD = 'Y'
go
select sum(CPU) from #cpuCount
go

Assuming #cpuCount doesn't exist:

select CPU into #cpuCount from Machine where PROD = 'Y'
go
select sum(CPU) from #cpuCount
Random Solutions  
 
programming4us programming4us