Report syntax examples

SQL statements to retrieve data from tables and columns (basic)

SQL Statement Syntax Example Statement Example Result or Description
SELECT
SELECT column_name(s)
FROM table_name

select Name from application

Use SELECT to get the data in one or more columns of a table.

SELECT *
SELECT *
FROM table_name
select * from ADGroup
 

Use SELECT to get all records from a table.

SELECT DISTINCT
SELECT DISTINCT column_name(s)
FROM table_name

select distinct ApplicationName from Event

Use SELECT DISTINCT to return just the values that are unique (distinct). Duplicate values are ignored.

UNION (ALL)
SELECT column_name(s) FROM table_name1
UNION
SELECT column_name(s) FROM table_name2

 

Use the UNION statement to combine result sets of two or more SELECT statements. Only distinct values are returned. To return all values, including duplicate values, use UNION ALL.