Fleet Analytics Definitions and Acronyms Data Manipulation Languages (DML) Data Definition Languages (DDL) Structured Query Language (SQL) o Transact Structured Query Language (T-SQL) – Microsoft o Procedure Language/Structured Query Language (PL/SQL) – Oracle Schema vs. Logins Aggregate Functions Deadlock Cartesian Product/Cross-Join Sub Query Syntax o Modifier o Expression o Clauses o Union, Join o Variable - Additional Syntax Wildcards and Patterns o % o _ o [] o [^] o Between Some Aggregates and Analytical o COUNT - Number of items in a group o SUM - Sum of column or expression from items in a group o AVG - Average of values in a group o MIN - Minimum value o MAX - Maximum value VAR - Statistical variance of all values Page | 1 Syntax Patterns Basic Select <column> from faster.<table> o SELECT EHKey FROM faster.EHeader Select <columns> from faster.<table> where <expression> o SELECT EHUid, EHCompany, EHKey FROM faster.EHeader WHERE EHStatus = 'A' Select <modifier> <columns> from faster.<table> where <expression> order by <column> o SELECT DISTINCT EHCompany, EHKey, EHDateCreated FROM faster.EHeader WHERE EHStatus = 'A' ORDER BY EHDateCreated Ranges and Wildcards Using Wildcards and Patterns ‘Like’ Clause o % - Percent SELECT <columns> FROM <table> WHERE <column> LIKE ‘%’ o _ - Underscore SELECT <columns> FROM <table> WHERE <column> LIKE ’1_00’ o [ ] Square Brackets SELECT <columns> FROM <table> WHERE <column> LIKE ’10[5-9]0’ OR <Column> LIKE ‘100[24680]’ o [^] – Square Brackets with Caret SELECT <columns> FROM <table> WHERE <column> LIKE ’100[1-4]’ Ranges of data using the ‘Between’ Clause o SELECT <columns> FROM <table> WHERE <column> BETWEEN <value> AND <value> o Joins and Unions – Note in graphical examples that the black is the included data and the white is the omitted data. Join Types: Left or Left Outer and Right or Right Outer Inner Outer Full Outer Using a left outer join returns a complete set of records from Table A, with the matching records (where available) in Table B. If there is no match, the right side will contain null. o SELECT <column> FROM <Table A> LEFT OUTER JOIN < Table B> ON ( <Table A>.<column> = <Table B.<column>) Page | 2 Using a right outer join returns a complete set of records from Table B, with the matching records (where available) in Table A. If there is no match, the left side will contain null. o SELECT <column> FROM <Table A> RIGHT OUTER JOIN < Table B> ON ( <Table A>.<column> = <Table B.<column>) Using a full outer join returns the set of all records in Table A and Table B, with matching records from both sides where available. If there is no match, the missing side will contain null. o SELECT <column> FROM <Table A> FULL OUTER JOIN < Table B> ON ( <Table A>.<column> = <Table B.<column>) Page | 3 Using an inner join returns only the set of records that match in both Table A and Table B. o SELECT <column> FROM <Table A> INNER JOIN < Table B> ON ( <Table A>.<column> = <Table B.<column>) Unions Union - Puts multiple rowsets with matching columns together Select <column list> from faster.<table 1> UNION Select <SAME column list> from faster.<table 2> Union ALL - Includes duplicates Page | 4 Examples 1) Example: Show the company, department, equipment number, and count of open work orders for active equipment numbers starting with ‘1’ and having more than 1 open work order --Main query SELECT DISTINCT EHCompany, EHDept,EHKey, ( --Nested Query in SELECT clause SELECT COUNT(WHUID) -- <--Aggregate function to return number of open -- work orders for the equipment matched row FROM faster.WHeader WHERE WHStatus NOT IN ('C','D') --<-- Using NOT operator with IN set AND WHEHUID = EHUID -- <--EHUID is from Main or outer query an limits our -- rows in WHeader to the row we are returning for EHeader ) "Open WO" -- <--using alias name for column name so we can include a space FROM faster.EHeader WHERE EHKey LIKE '1%' --< using like operator with % wild card AND EHStatus = 'A' GROUP BY EHCompany,EHDept, EHKey,EHUID HAVING --<-- Having clause to limit our records with nested query ( --Nested Query in Having cluse SELECT COUNT(WHUID) FROM faster.WHeader WHERE WHStatus NOT IN ('C','D') AND WHEHUID = EHUID ) >1 ORDER BY EHCompany,EHDept,EHKey --<--Order By clause to sort our results 2) Work Order Aging a. Syntax i. DISTINCT ii. BETWEEN b. Creating a view c. Using Joins d. Using Aggregates i. COUNT e. Using Functions i. ISNULL / NVL ii. GetDate() Page | 5 iii. DATEDIFF iv. FCS_INT2DATETIME 3) Asset Availability a. Syntax i. DISTINCT ii. GROUP BY b. Using Joins c. Using Aggregates Function i. COUNT 4) Carbon Footprint a. Syntax i. DISTINCT ii. GROUP BY b. Using Joins c. Using Aggregates Function i. COUNT Page | 6