You can use decode for that:

Select
count(decode(myfield,'Running',1,null)) as cnt_Running,
count(decode(myfield,'Offline',1,null)) as cnt_Offline,
count(decode(myfield,'Unknown',1,null)) as cnt_Unknown
count(myfield) as total_Count


(where myfield is the field that returns the Running, Offline or Unknown text)

HTH,
Tim P.

----- Original Message ----- 
From: "Edwards Robert (air0rae)" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, September 10, 2002 3:17 PM
Subject: OT: Stupid SQL Problem (in oracle)


> I need some way to convert a word into a number.
> 
> I know I've done it once before, but I can't remember what I did.
> 
> For example, I have a query that will return something like the following:
> 
> Machine1     Running
> Machine2    Running
> Machine3    Offline
> Machine4    Running
> Machine5    Offline
> Machine6    Unknown
> 
> 
> I want to get some result like this:
> 
> Running     Offline    Unknown    Total
> 3                 2             1               6
> 
> I know it has something to do with a sum and translating "Running" into 1,
> "Offline" into a 1 and "Unknown" into a 1,  I just can't remember how I did
> it.
> 
> This is an oracle 8i system I'm working with.
> 
> Thanks,
> 
> 
> Rob Edwards         Phone: (502) 359-1627
> Systems Management Tools   Pager: (502) 478-1116
> United Parcel Service Fax: (502) 359-0094
> EMail: [EMAIL PROTECTED] 
> 
> (2B || !2B) == ?
> 
> 
> 
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to