Coming back to technical writing is a tough ask. Simply because it takes much of accurate stuff to fill details & also something which is helpful for most of blog readers since I am not writing a chapter by chapter tutorial.
So I decide to touch SQL query building here. I will not be going much in detail - will be just give some pointers and notes that I always try to remember myself with.
First thing when it comes to a SQL query I remember is the structure -
SELECT column_list
FROM table_list
WHERE condition_list
GROUP BY column_list_for_grouping
HAVING condition_list
HAVING condition_list
ORDER BY column_list_for_ordering
Tips:
1. Order by clause is always at the end of the SQL statement.
2. Group by clause should mention all the column names that are present in the select statement. The columns on which aggregate function is used can be avoided.
Let us relate the SQL query structure to a SAP Business objects - Web Intelligence report. Custom sort is an option that is readily available in Web Intelligence reports. Easy to understand - it provides 3 options as Ascending, Descending and custom order.
How to Apply Sort to a Report in Web Intelligence:
1. Open a Web Intelligence report. Select the section or table cells you want to sort.
2. Click the down arrow next to the "Apply/Remove Sort" button on the Report toolbar.
webi sort - icon |
3. Select "Ascending," "Descending" or "Custom" from the list of sort options.
4. Click on a value in the list if you're applying a "Custom" sort. Click the up or down arrow to promote or demote the value in the sort order. Type a value in the "Temporary Values" box and click the double-arrow button if you want to add a temporary value to the sort list.
Another option is to change the Query panel's query (button click - View SQL) and provide Order By clause at the end. This will not work in case the source for WebI report is a SAP BW query whether Universe designer is used or not.
Query panel and View SQL (2nd row last icon) |
Grouping however, can be accompolished by various options. I will take you through in upcoming posts. As of now - here are some ways of achieveing grouping in a web intelligence report.
1. Create variable and assign group of values to it. Perform required aggregate function on it. This is however for a complex require which is rare.
2. Use of Breaks - naturall groups for aggregate functions
3. Use of Sections- most easy and common way to achieve grouping
Select the dimension which should be displayed as section > Click Reporting > Set as Section
![]() |
Section created on Month |
Sections can be applied and formatted to function more or less like breaks; however, breaks can never function as sections do, they are limited to the scope of the block on which they are defined. I tend to prefer sections as they allow for greater flexibility and they seem to have more options. Even then, breaks can be excellent for grouping relatively small amounts of data and then aggregating the measures at the bottom of the table.
WebI - Section and Break |
In SQL - aggregate functions are very important. The reason is simple - because it provides necessary information in the summary format.
Below is the list of useful aggregate functions that can be used when grouping data to display summary output:
- AVG() - Returns the average value
- COUNT() - Returns the number of rows
- FIRST() - Returns the first value
- LAST() - Returns the last value
- MAX() - Returns the largest value
- MIN() - Returns the smallest value
- SUM() - Returns the sum
More to come, hopefully.