SELECT date, loc, SUM(CASE WHEN type = 'AP' THEN numbercolumn ELSE 0 END) AS AP,
SUM(CASE WHEN type = 'PL' THEN numbercolumn ELSE 0 END) as PL
FROM yourtable
GROUP BY date loc

On 8/16/05, Ian Skinner <[EMAIL PROTECTED]> wrote:
> Without commenting on the possible double entendre of the subject; is there 
> an easy way to convert rows of a query into columns.
> 
> I would like to take something that looks like this:
> DATE     LOC #   TYPE
> -------- --  --- ----
> 20050706 NS  14  AP
> 20050706 NS  1   PL
> 20050706 NS  21  WB
> 20050706 SM  104 AP
> 20050706 SM  39  PL
> 20050706 SM  291 WB
> 
> And make it look like this:
> DATE     LOC AP  PL  WB
> -------- --- --- --- ---
> 20050706 NS  14  1   21
> 20050706 SM  104 39  291
> 
> If it matters this is for a CF6.1 & Oracle system.
> 
> --------------
> Ian Skinner
> Web Programmer
> BloodSource
> www.BloodSource.org
> Sacramento, CA
> 
> "C code. C code run. Run code run. Please!"
> - Cynthia Dunning
> 
> Confidentiality Notice:  This message including any
> attachments is for the sole use of the intended
> recipient(s) and may contain confidential and privileged
> information. Any unauthorized review, use, disclosure or
> distribution is prohibited. If you are not the
> intended recipient, please contact the sender and
> delete any copies of this message.
> 
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:215247
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to