Query

  • Hi
      I have  query which returns Location , Vendor , Amount. Query is grouped by Location & Vendor Suppose 3 records are returned . But further i want to display the details of these 3 records from the table . Here Amount is consolidated . Only 1 table is used. 
    I want external query should display all the records of that Location & Vendor record wise which have been returned by internal query

      Location        Vendor              Amount
       A                   X                        10000
       B                   Y                         20000
       C                   Z                         30000

  • Hi jagjitsingh,

    I don't mean to be rude, but you've been asked and shown enough times to post your questions properly (with DDL, Consumable Sample Data, Expected results, etc). Could you perhaps, do so please?

    Thanks.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Maybe the ROLLUP operator could help?
    https://technet.microsoft.com/en-us/library/ms189305(v=sql.90).aspx
    You would have to change your GROUP BY to include the additional columns that you want to aggregate at the lower level by.  If there's too many columns to group by, it may make more sense to get the details, then UNION ALL with the summary?  It's difficult to tell without more information as Thom suggested.

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

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