SQL Server 2008 -  ROLL UP function

Posted on 2011-05-05
Last Modified: 2012-06-21

I recently stumbled across the ROLL UP function in SQL Server, apparently there are two synatx of it where one is

1) GROUP BY fieldname1,fieldname2 WITH ROLL UP

2) GROUP BY ROLL UP (fieldname1, fieldname2)

I was wondering if there's a difference to the two syntax? I'm returning the same results with either. Thank you.
Question by:Shino_skay
    LVL 40

    Accepted Solution

    Both are same but "WITH ROLLUP" is Non-ISO Compliant Syntax.
    Please read this:

    Non-ISO-Compliant Syntax
    [ GROUP BY [ ALL ] group_by_expression [ ,...n ]
        [ WITH { CUBE | ROLLUP } ] 

    Open in new window

    LVL 21

    Assisted Solution

    by:Alpesh Patel

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now