Help with select group by on a view

  • Hi every one, so I have this view:

    SELECT dbo.MOP10213.MANUFACTUREORDER_I, dbo.IV30300.DOCNUMBR, dbo.IV30300.DOCDATE AS fecha, dbo.IV30300.TRXSORCE

    FROM dbo.MOP10213 INNER JOIN

    dbo.IV30300 ON dbo.MOP10213.IVDOCNBR = dbo.IV30300.DOCNUMBR

    GROUP BY dbo.IV30300.DOCNUMBR, dbo.MOP10213.MANUFACTUREORDER_I, dbo.IV30300.TRXSORCE, dbo.IV30300.DOCDATE

    But I want to add two or 3 more columns, but don't want them added, or counted, and def. not in the group by statement, I need this columns to show the value they have.

    How can this be done?

    Thanks and regards,

  • alvaro-454996 (2/25/2013)


    Hi every one, so I have this view:

    SELECT dbo.MOP10213.MANUFACTUREORDER_I, dbo.IV30300.DOCNUMBR, dbo.IV30300.DOCDATE AS fecha, dbo.IV30300.TRXSORCE

    FROM dbo.MOP10213 INNER JOIN

    dbo.IV30300 ON dbo.MOP10213.IVDOCNBR = dbo.IV30300.DOCNUMBR

    GROUP BY dbo.IV30300.DOCNUMBR, dbo.MOP10213.MANUFACTUREORDER_I, dbo.IV30300.TRXSORCE, dbo.IV30300.DOCDATE

    But I want to add two or 3 more columns, but don't want them added, or counted, and def. not in the group by statement, I need this columns to show the value they have.

    How can this be done?

    Thanks and regards,

    You are going to have to provide more details. Which value for these columns do you want? The minimum, max, first, last, random? You will either need to aggregate these columns or include them in the group by.

    Please take a few minutes to read the article found at the first link in my signature for best practices when posting questions.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

Viewing 2 posts - 1 through 2 (of 2 total)

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