Using database functions for advanced reporting
A database function is a custom function that extends reporting capabilities while using the service management data. You can use these functions to integrate the AR System data with BMC Helix Dashboards and perform complex database transformations that are difficult to achieve by using the standard AR System workflow.
Before you begin
Before you add database functions in the SQL editor of a dashboard to meet your specific business needs, define the database functions that you want to use in the AR System JDBC:Generic Db Functions form on the AR System server.
For more information, see Defining database functions in AR System Server.
To use a database function in a query
- Log in to BMC Helix Portal, and open BMC Helix Dashboards.
- Click New dashboard.
- From the Query Type list, select Service Management.
- From the Type list, select SQL.
- In the SQL editor, define a SQL query by using database functions.
- Configure the required visualization.
- Save the dashboard.
Examples of database functions
The following tables describe some of the database functions:
| Function name | Description | Example query to be used in the SQL editor |
|---|---|---|
| Ascending rank | Displays the column values in ascending order. | SELECT DBFN('rank;over;order by count',2,'#KWD#(','#KWD#)',1,'#KWD#(',5,'#KWD#(',`Incident Number`,'#KWD#)','#KWD#asc','#KWD#)') as RANK , count(`HPD:Help Desk`.`Incident Number`) AS inccount, `HPD:Help Desk`.`Status` as Status FROM `HPD:Help Desk` group by Status where,
|
| Descending rank | Displays the column values in descending order. | SELECT DBFN('rank;over;order by count',2,'#KWD#(','#KWD#)',1,'#KWD#(',5,'#KWD#(',`Incident Number`,'#KWD#)','#KWD#desc','#KWD#)') as RANK , count(`HPD:Help Desk`.`Incident Number`) AS inccount, `HPD:Help Desk`.`Status` as Status FROM `HPD:Help Desk` group by Status |
| Top 10 rank | Displays the highest 10 values in the column | select * from (SELECT DBFN('rank;over;order by count',2,'#KWD#(','#KWD#)',1,'#KWD#(',5,'#KWD#(',`Incident Number`,'#KWD#)','#KWD#desc','#KWD#)') as rnk1 , count(`HPD:Help Desk`.`Incident Number`) AS inccount, `HPD:Help Desk`.`Status` as Status FROM `HPD:Help Desk` group by T1.Status) as T1 where rnk1 <=10 |
| Top N rank | Displays the number of highest values as requested by the user for that column. | Display the number of highest values by using the combination of a variable and the rank() database Create a variable and specify this variable in the SQL query. For example, specify the following query in the SQL editor to display the number of highest values as requested by the user: |
| Bottom 10 rank | Displays the lowest 10 values in the column. | select * from (SELECT DBFN('rank;over;order by count',2,'#KWD#(','#KWD#)',1,'#KWD#(',5,'#KWD#(',`Incident Number`,'#KWD#)','#KWD#asc','#KWD#)') as rnk1 , count(`HPD:Help Desk`.`Incident Number`) AS inccount, `HPD:Help Desk`.`Status` as Status FROM `HPD:Help Desk` group by T1.Status) as T1 where rnk1 <=10 |
| Bottom N rank | Displays the number of lowest values as requested by the user for that column. | Display the number of lowest values by using the combination of a variable and the rank() Create a variable and specify this variable in the SQL query. For example, specify the following query in the SQL editor to display the select * from (SELECT DBFN('rank;over;order by count',2,'#KWD#(','#KWD#)',1,'#KWD#(',5,'#KWD#(',`Incident Number`,'#KWD#)','#KWD#asc','#KWD#)') as rnk1 , count(`HPD:Help Desk`.`Incident Number`) AS inccount, `HPD:Help Desk`.`Status` as Status FROM `HPD:Help Desk` group by T1.Status) as T1 where rnk1 <= $Rank |
| Natural Logarithm | Displays the base logarithm of the values of a given field/column. | Display the base logarithm of the field values by using the DBFN function. For example, use the following query in the SQL editor DBFN('log','2.0',`number`) |
| Top N with ties | Displays the top values for the selected field with provision for tied values. If there are multiple records per ranking, this function restricts it to N total rankings. | Display the top values for selected fields by using the combination of a variable and the Create a variable and specify the newly created variable in the SQL query. For example, specify the following query in the SQL editor: |
| Count | Advanced authoring | SELECT * FROM (select * , DBFN('COUNT;OVER;PARTITION BY;ORDER BY', 3, '#KWD#(' , '#KWD#*' , '#KWD#)' , 1, '#KWD#(', 1 , `Support Group Name`, 3, `Submit Date` , '#KWD#DESC' , '#KWD#)') as group_rank FROM `HPD:HelpDesk_CTM_ServiceCompany_SupportGroup_Join`) ranked where group_rank <= 20 |
| Lag | Displays values from the previous table rows for comparison. | SELECT DBFN('lag;over;partition by;order by', 4, '#KWD#(' , `Short Description` , 1 , '#KWD#)' , 1, '#KWD#(' , 1 , `Short Description` , 2 , `Short Description` , '#KWD#)') FROM 'AR System Schema'.'Test:Form' where,
|