• Krishna1 (6/26/2013)


    What i wanted was like cube or rollup is there a way to make single query rather than union

    These functions are available in SQL Server (2008+). Take a look at http://msdn.microsoft.com/en-us/library/bb522495(v=sql.105).aspx

    So it would be something like:

    SELECT

    xx

    , sum(Yy) as total

    FROM tablea

    GROUP BY ROLLUP (Xx)

    ** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **