Home Forums SQL Server 2008 T-SQL (SS2K8) Need suggestions on dividing two rows within a CASE statement RE: Need suggestions on dividing two rows within a CASE statement

  • 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 AXXX Inventory (A) 84

    2014-07-21 00:00:00.000 AXXX Inventory with Lead 45

    2014-07-21 00:00:00.000AXXX 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