Posts

Showing posts with the label Group By & Difference between WHERE and HAVING clause

Using BAPI upload excel file for t-code AS02 in SAP

Using BAPI " BAPI_FIXEDASSET_CHANGE " create a zprogram to upload excel file for mass change fixed asset in SAP. REPORT  ZAS02_ASSET_CHANGE_UPLOAD . TYPE-POOLS :  truxs . " Structure for Excel data TYPES :  BEGIN  OF  ty_excel ,          anln1  TYPE  anln1 ,          bukrs  TYPE  bukrs ,          kostl  TYPE  kostl ,          werks  TYPE  werks ,          prctr  TYPE  prctr ,         END  OF  ty_excel . DATA :  lt_excel     TYPE  TABLE  OF  ty_excel ,       ls_excel     TYPE  ty_excel ,     ...

Group By & Difference between WHERE and HAVING clause

Group By: In SQL Server we have got lot of aggregate functions. Likes: 1. Count() 2. Sum() 3. avg() 4. Min() 5. Max() Group by clause is used to group a selected set of rows into a set of summary rows by the values of one or more columns or expressions. It is always  used in conjunction with one or more aggregate functions. Syntax look likes : SELECT COUNT (Column name), column name1 FROM table name GROUP BY column name1; Filtering Groups:   WHERE clause is used to filter rows before aggregation, where as HAVING clause is used to filter groups after aggregations. The following 2 queries  produce the same result. Filtering rows using WHERE clause, before aggregations take place: Select Column name, SUM (column name) from table name Where column name = condition group by column name (By which we want to filter our result) Filtering groups using HAVING clause, after all aggregations take place: Select Column name, SUM (column name) from t...