[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

if else statment in sybase

Posted on 2008-11-17
2
Medium Priority
?
1,250 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:Kaydensun
2 Comments
 
LVL 10

Accepted Solution

by:
bret earned 1500 total points
ID: 22977503
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
0
 

Author Closing Comment

by:Kaydensun
ID: 31517485
Thank you for you solution.  
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question