This section is not intended to be a course of the SQL language. Therefore, the focus will be put on the minimal set of differences that you must know in order to write queries properly.
...
Expand |
---|
|
Code Block |
---|
| select * from PROJECT |
will work. Whereas Code Block |
---|
| select * from project |
will not. |
KEY is a reserved word
As other database vendors, SQL Cloud does have reserved words that must be surrounded with accents or square brackets
...
Expand |
---|
|
These are the rules for conditions resolution: The table in FROM clause will get the conditions from the WHERE clause directly The rest of the tables will take them from the JOIN ON conditions only.
In other words: (order of execution) WHERE conditions will be applied only to the table only (FROM) at the beginning of the query resolution. Next, JOINs will be resolved taking only ON conditions into consideration (WHERE conditions will be ignored here at this stage) The rest of the WHERE conditions will be applied after all the JOINS have been resolved
|
...
Expand |
---|
|
Please pay attention to the having condition: count(*) > 2 Code Block |
---|
| SELECT `i`.`KEY`as `Issue`, count(*) as `Num. comments`
FROM ISSUE `i`
LEFT JOIN ISSUECOMMENT `ic` ON `ic`.`ISSUEID` = `i`.`ID`
WHERE `i`.`JQL` = 'PROJECT = TALH'
GROUP BY `i`.`KEY`
HAVING count(*) > 2 |
Works! In this query the condition has been modified to uses column aliases: `Num. comments` > 2 Code Block |
---|
SELECT `i`.`KEY`as `Issue`, count(*) as `Num. comments`
FROM ISSUE `i`
LEFT JOIN ISSUECOMMENT `ic` ON `ic`.`ISSUEID` = `i`.`ID`
WHERE `i`.`JQL` = 'PROJECT = TALH'
GROUP BY `i`.`KEY`
HAVING `Num. comments` > 2 |
Not works! |