Creating reports with advanced database functions by using Advanced Authoring
Use the Advanced Authoring option to create reports with complex database queries. You can use complex database functions that contain multiple parts (such as over, partition by, order by) in a single function.
Important
- You can use Advanced Authoring for MS SQL and Oracle databases only.
- Advanced Authoring or Freehand SQL reports do not support User Prompts & Source Filters.
To use Advanced Authoring, you must have the Admin, Corp Writer, or Report Writer role.
To create a report using Advanced Authoring
- On the Remedy Smart Reporting Admin Console, click the + button, and select Report.
- In the New Report window:
- Enable Advanced Authoring.
- From the Author Method list, select Freehand SQL.
- From the Data Source list, select a data source.
- Click Create Analysis button at the bottom of the New Report window.
- To write complex queries, in the SQL Query editor, perform the following steps:
Enter the SQL query for creating the report.
Make sure you give an alias in the SELECT statement. For example:
SELECT DISTINCT
`HPD:Help Desk`.`Incident Number` AS C1,
`HPD:Help Desk`.`Status` AS C2
FROM `AR System Schema`.`HPD:Help Desk`For examples of complex queries, see the examples below.
- Click Validate.
- Click Save.
The calculation is available in an SQLFields folder on the Data page, and the report data is displayed on the right.
Examples of how to execute complex database functions having multiple parts
The following examples show how you can execute complex functions by using the Advanced Authoring option.
Example 1
To run this function, enter the following query in the SQL Query editor:
The following table describes how to interpret the DBFN functionality:
Argument | Description |
---|---|
lag;over;partition by;order by | Indicates all parts in the function. |
4 | Indicates the number of arguments in the first part: (, Short_desc, 1, and ) |
1 | Indicates the number of arguments in the next part over, which has only one argument: ( which is prefixed by #KWD#. |
1 | Indicates the number of arguments in the next part partition by, which has only one argument Short Description. |
2 | Indicates the number of arguments in the next part order by, which has only two arguments: Short Description and ). The final closing bracket is prefixed as #KWD#). |
The flow continues as shown in the table for all the arguments in a function that has multiple parts.
Example 2
To run this function, enter the following query in the SQL Query editor:
The following table describes how to interpret the DBFN functionality:
Argument | Description |
---|---|
rank;over;order by;count | Indicates all parts in the function. |
2 | Indicates the number of arguments in the first part: (, and ) |
1 | Indicates the number of arguments in the next part over, which has only one argument: ( which is prefixed by #KWD#. |
5 | Indicates the number of arguments in the next part order by count, which has 5 arguments (, Incident_Number, ), desc, and ). The opening and closing brackets are prefixed with the string #KWD#. For example, #KWD#( or #KWD#). |
Example of a Union subquery
Consider the following example of a Union subquery that you can construct by using the Advanced Authoring option:
`HPD:Help
Desk`.`Incident Number` AS 'TicketNumber',
`HPD:Help Desk`.`Assigned Support Company` AS
'AssignedSupporCompany',
`HPD:Help Desk`.`Status` AS 'TicketStatus',
`HPD:Help Desk`.`Priority` AS 'TicketPriority'
FROM `AR
System Schema`.`HPD:Help Desk`
UNION
SELECT DISTINCT
`PBM:Problem
Investigation`.`Problem Investigation ID` AS 'TicketNumber',
`PBM:Problem Investigation`.`Assigned Support
Company` AS 'AssignedSupporCompany',
`PBM:Problem Investigation`.`Investigation
Status` AS 'TicketStatus',
`PBM:Problem Investigation`.`Priority` AS
'TicketPriority'
FROM `AR
System Schema`.`PBM:Problem Investigation`
Example of an Append subquery
Consider the following example of an Append subquery that you can construct by using the Advanced Authoring option:
HPDHELPDESK.TicketNumber,
HPDHELPDESK.TicketAssignee,
HPDWORKLOG.Summary
FROM (
SELECT DISTINCT
`HPD:Help
Desk`.`Incident Number` AS 'TicketNumber',
`HPD:Help Desk`.`Assignee` AS
'TicketAssignee'
FROM `AR System
Schema`.`HPD:Help Desk`
) HPDHELPDESK
LEFT OUTER JOIN (
SELECT DISTINCT
`HPD:Help
Desk`.`Incident Number` AS 'IncNumber',
`HPD:WorkLog`.`Description` AS 'Summary'
FROM `AR System Schema`.`HPD:Help
Desk`
LEFT OUTER JOIN `AR System
Schema`.`HPD:WorkLog`
ON (
`HPD:Help
Desk`.`Incident Number` = `HPD:WorkLog`.`Incident Number`
)
) HPDWORKLOG
ON HPDHELPDESK.TicketNumber=
HPDWORKLOG.IncNumber