SQL
You can query the tables using standard SQL query.
SELECT t1.movie_id, t2.name, avg(rating) avg_rating, count(1) rating_count FROM ratings t1 join movies t2 on t1.movie_id = t2.id GROUP BY t1.movie_id, t2.name HAVING count(1) > 100 ORDER BY avg_rating desc
Grammar: SQL grammar in BNF-like form.
statement:
| query
statementList:
statement [ ';' statement ]* [ ';' ]
query:
select
| query UNION [ ALL | DISTINCT ] query
| query EXCEPT [ ALL | DISTINCT ] query
| query MINUS [ ALL | DISTINCT ] query
| query INTERSECT [ ALL | DISTINCT ] query
[ ORDER BY orderItem [, orderItem ]* ]
[ LIMIT [ start, ] { count | ALL } ]
[ OFFSET start { ROW | ROWS } ]
orderItem:
expression [ ASC | DESC ] [ NULLS FIRST | NULLS LAST ]
select:
SELECT [ DISTINCT ]
{ * | projectItem [, projectItem ]* }
FROM tableExpression
[ WHERE booleanExpression ]
[ GROUP BY { groupItem [, groupItem ]* } ]
[ HAVING booleanExpression ]
projectItem:
expression [ [ AS ] columnAlias ]
| tableAlias . *
tableExpression:
tableReference [, tableReference ]*
| tableExpression [ { LEFT | RIGHT | FULL } [ OUTER ] ] JOIN tableExpression [ joinCondition ]
joinCondition:
ON booleanExpression
tableReference:
tableName
[ [ AS ] alias ]
groupItem:
expression
| '(' ')'
| '(' expression [, expression ]* ')'
In orderItem, if expression is a positive integer n, it denotes the nth item in the SELECT clause.
An aggregate query is a query that contains a GROUP BY or a HAVING clause, or aggregate functions in the SELECT clause. In the SELECT, HAVING and ORDER BY clauses of an aggregate query, all expressions must be constant within the current group (that is, grouping constants as defined by the GROUP BY clause, or constants), or aggregate functions, or a combination of constants and aggregate functions. Aggregate and grouping functions may only appear in an aggregate query, and only in a SELECT, HAVING or ORDER BY clause.
SQL Functions
NOW
Current time in UTC timezone
Examples:
TODAY
Current date in UTC timezone
Examples:
USER_ID
Id of the current user.
Examples:
ACCOUNT_ID
Id of the current user's account.
Examples: