Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Need suggestions on dividing two rows within a CASE statement Rate Topic Display Mode Topic Options
Author
 Message
 Posted Monday, July 28, 2014 12:12 PM
 Valued Member Group: General Forum Members Last Login: Tuesday, November 22, 2016 12:38 PM Points: 68, Visits: 508
Post #1597013
 Posted Monday, July 28, 2014 1:06 PM
 SSCrazy Eights Group: General Forum Members Last Login: Today @ 11:07 AM Points: 8,225, Visits: 17,791
 I don't understand. You say you need to divide the result of a CASE statement, but the result is a string. What are your expected results? A CTE or a subquery could help you to work with the CASE statement as a simple column.If more help is needed, please post DDL and sample data for [TIM_PurchaseOffer] table. Luis C.General Disclaimer:Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?How to post data/code on a forum to get the best help: Option 1 / Option 2
Post #1597037
 Posted Monday, July 28, 2014 1:55 PM
 Valued Member Group: General Forum Members Last Login: Tuesday, November 22, 2016 12:38 PM Points: 68, Visits: 508
 Hello Luis,I need to divide using the DailyCount filed which is in the example below:SUM(CASE WHEN BF_OFFER_CODE IS NOT NULL THEN 1 ELSE 0 END) 'DailyCount'2014-07-21 00:00:00.000 A XXX Inventory (A) 842014-07-21 00:00:00.000 A XXX Inventory with Lead 452014-07-21 00:00:00.000 A XXX Inventory Opt-In Rate 34%Both the 84 and 45 numbers are derived from the above CASE statement. What I need to do is create a new row named XXX Inventory Opt-In Rate (row in boldface) and divide the 45 number, which is the XXX Inventory with Lead number by the total grouping for XXX with is 129 (84+45)Thanks
Post #1597050

 Permissions