Tring to add a ''=========='' to result set

  • Are trying to create reporting tool out of single query?

    Answer on your last question depends on:

    where you going supply results to;

    what kind of presentaton format you gonna use;

    etc...

    But actually SQL Server suppose to supply data, there are other applications for creating presentations.

    _____________
    Code for TallyGenerator

  • I know how to do it in vb.net but was wondering if a querry might save some time.. When i ran across the Grouping  with rollup... that is what opened this can of worms up.. FOR the rollup up i will be using that in a datagrid,, but was looking into other option for a divider inside a drop downlist... ddl

    erik.

    Dam again!

  • "... but was looking into other option for a divider inside a drop downlist"

    Another method to skin that cat it to use union queries.

    DECLARE @tbl table ( grp varchar(4), field int )
    INSERT INTO @tbl VALUES ('ABC', 1)
    INSERT INTO @tbl VALUES ('ABC', 2)
    INSERT INTO @tbl VALUES ('DEF', 3)
    INSERT INTO @tbl VALUES ('DEF', 4)
    INSERT INTO @tbl VALUES ('GHI', 5)
    INSERT INTO @tbl VALUES ('GHI', 6)
    SELECT 1 as [ord], grp, CAST(SUM(field) as varchar(6)) as GrpCnt
    FROM @tbl
    GROUP BY grp
    UNION
    SELECT 2, grp, '----'
    FROM @tbl
    GROUP BY grp
    UNION
    SELECT 3, '', CAST(SUM(field) as varchar(6))
    FROM @tbl
    UNION
    SELECT 4, '', '===='
    ORDER BY grp DESC, [ord]
     

    --------------------
    Colt 45 - the original point and click interface

  • i see your guy on the left banging his head... thats what mine feels like..

     

    thank you very much! for the code!

    erik...

    Dam again!

  • Server: Msg 170, Level 15, State 1, Line 11

    Line 11: Incorrect syntax near '@tblGROUP'.

    Dam again!

  • Looks like your copy and paste didn't work. There should be a line break or space in between @tbl and GROUP

     

    --------------------
    Colt 45 - the original point and click interface

  • Just copyed and pasted into a word doc. then pasted into analyer.. works great..

     really nifty looking.  I will spend some time with it,, to try to learn more about the way that you have implemeted this.  I need to get a better understanding of unions..

    thanks,

    erik

    Dam again!

Viewing 7 posts - 16 through 21 (of 21 total)

You must be logged in to reply to this topic. Login to reply