Welcome to The Community. The community is designed to share information on SAP HANA in an interactive way.

Visit SAPHANATutorial.Com
Difference Between Aggregation and Projection
  • Hi Admin/All

    Could anyone please brief me with clear and crisp description that what is the difference between Aggregation and Projection.I went through many online documents but i could not see any much difference and much discussion in this regard.

    Thanks,
    Pradeep
  • In simple words,

    Projection: is used to fetch few columns of a table instead of all the columns.

    Aggregation: is used to apply a aggregation function (SUM, MAX or MIN) on table.

    Let’s take a simple example.

    There is a table TABLE1 like below.

    image


    Now if you want NAME and COMPANY only then the query will be:

    SELECT NAME, COMPANY from TABLE1;

    image

    Or if you want COMPANY, SALARY and you need all the records, then the query will be

    SELECT COMPANY, SALARY from TABLE1;

    image

    Note that in above query it fetches all the records. It has 2 records for COMPANY1.


    Both of the above are example of PROJECTION.


    Now suppose instead of fetching all the records you want to some aggregation. 

    For example, fetch the sum of SALARY for each COMPANY. Then the query will be:

    SELECT COMPANY, SUM(SALARY) from TABLE1 GROUP BY COMPANY;

    image

    Note that in above query, 2 records of COMPANY1 has been aggregated to one single record.

  • Thanks a lot Admin, that was very helpful....

Howdy, Stranger!

It looks like you're new here. Sign In using your Gmail ID, Click on 'Google' button to sign in

Free Online Training Programs under SAPHANATutorial.com:
Click here to start SAP HANA Basics online course.
© 2016 : saphanatutorial.com, All rights reserved.
Visit SAPHANATutorial.Com