Group By All Non-Aggregated Columns not listing all non-aggregated columns

CorvetteFanCorvetteFan Posts: 2 New member
edited February 23, 2023 1:29PM in SQL Prompt
When I use the super handy Group By All Non-Aggregated Columns feature of SQL prompt, I've often seen it not list all of the columns it should out of the non-aggregated ones. Does length or complexity of the script affect it? Also, does the order you have columns in the select list affect it (i.e, let's say CASE statements are in use and/or the aggregated columns are mixed up throughout the select list rather that bunched up towards the end of the select list together)?

Answers

  • Hi @CorvetteFan
    Thanks for reaching out on the Redgate forums and apologies for the delay in a reply on this one.

    I've attempted some replications but aren't quite getting the same outcome.

    Can you confirm your SQL Prompt version and perhaps provide a screenshot of values that are missing from your expected output.
    Selection order shouldn't have a bearing on this, but happy to do some more testing to be more definitive on that one.

    If you have some extra info and the product version that would be greatly appreciated.
    Jon Kirkwood | Technical Support Engineer | Redgate Software
  • MarshallRMarshallR Posts: 1 New member
    edited August 28, 2024 6:58PM
    I had this situation come up today where I used the "All Non-Aggregated Columns" after typing in the group by and did not add all of them to the group by.
    Here is my select (the one aggregated column pointed out):


    Here is the Group By it created:


    It is missing quite a few columns. Some examples are
    a.model_number AS ModelNumber,
    a.manufacturer AS Manufacturer,
    c.description AS Category,
    pr.Room,
    pr.RoomType

    here is the SQP Prompt Version:


    I tried refreshing suggestions and re-doing it and got the same results.
    Any idea what would cause this?

    Thanks!
Sign In or Register to comment.