Skip to content

Commit 8fc0302

Browse files
Keyword addition
1 parent 6154572 commit 8fc0302

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

query/src/org/labkey/query/controllers/prompts/LabKeySql.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ LabKey SQL allows you to create virtual columns within a query by using SQL expr
3434
`SELECT expression AS column_name FROM table`
3535
* **Functionality:**
3636
The syntax involves performing a calculation and then aliasing the result with a new column name using the `as` keyword.
37+
* **Reserved words as aliases:** SQL function names (`COUNT`, `SUM`, `AVG`, `MIN`, `MAX`) and other SQL keywords are reserved and cannot be used as bare column aliases. Quote them or choose a different name:
38+
```sql
39+
-- Wrong: COUNT(MouseId) AS Count → parse error
40+
-- Right: COUNT(MouseId) AS "Count"
41+
-- Right: COUNT(MouseId) AS TotalCount
42+
```
3743
* **Examples:**
3844
* **Pulse Pressure:** To calculate pulse pressure from systolic and diastolic blood pressure values:
3945
```sql

0 commit comments

Comments
 (0)