Lines Matching refs:BY
2412 ** to an ORDER BY clause, all fields required by the caller are present in the
4318 ** or in an ORDER BY or GROUP BY clause.</dd>)^
7460 ** ^Information about the ORDER BY clause is stored in aOrderBy[].
7461 ** ^Each term of aOrderBy records a column of the ORDER BY clause.
7493 ** the correct order to satisfy the ORDER BY clause so that no separate
7542 int nOrderBy; /* Number of terms in the ORDER BY clause */
7546 } *aOrderBy; /* The ORDER BY clause */
10033 ** is doing a GROUP BY.
10052 ** that have both DISTINCT and ORDER BY clauses.
12831 ** ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid
13324 ** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.
17250 #define SQLITE_OrderByIdxJoin 0x00000040 /* ORDER BY of joins via index */
17263 #define SQLITE_OmitOrderBy 0x00040000 /* Omit pointless ORDER BY */
18520 u16 iOrderByCol; /* For ORDER BY, column number in result set */
18603 unsigned isIndexedBy :1; /* True if there is an INDEXED BY clause */
18624 char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */
18676 #define WHERE_ORDERBY_MIN 0x0001 /* ORDER BY processing for min() func */
18677 #define WHERE_ORDERBY_MAX 0x0002 /* ORDER BY processing for max() func */
18683 #define WHERE_GROUPBY 0x0040 /* pOrderBy is really a GROUP BY */
18821 ** sequences for the ORDER BY clause.
18833 ExprList *pGroupBy; /* The GROUP BY clause */
18835 ExprList *pOrderBy; /* The ORDER BY clause */
18859 #define SF_Aggregate 0x0000008 /* Contains agg functions or a GROUP BY */
18878 #define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */
18883 #define SF_OrderByReqd 0x8000000 /* The ORDER BY clause may not be omitted */
18934 ** the ORDER BY clause.
18971 /* The ORDER BY clause is ignored for all of the above */
19573 ExprList *pGroupBy; /* GROUP BY clause */
19719 ExprList *pPartition; /* PARTITION BY clause */
19720 ExprList *pOrderBy; /* ORDER BY clause */
19737 int regPart; /* Array of registers for PARTITION BY values */
31756 sqlite3TreeViewExprList(pView, pWin->pPartition, nElement>0,"PARTITION-BY");
31759 sqlite3TreeViewExprList(pView, pWin->pOrderBy, (--nElement)>0, "ORDER-BY");
32374 sqlite3TreeViewExprList(pView, pOrderBy, (--n)>0, "ORDER-BY");
32516 sqlite3TreeViewExprList(pView, pOrderBy, (--n)>0, "ORDER-BY");
97202 "SELECT*FROM\"%w\".%s WHERE %s ORDER BY rowid",
99790 ** or by SELECT statements with ORDER BY clauses that cannot be satisfied
99805 ** the ORDER BY key columns and result columns
99806 ** in the case of a SELECT w/ ORDER BY, or
103731 ** SELECT a+b, c+d FROM t1 ORDER BY 1 COLLATE nocase;
103735 ** SELECT a+b, c+d FROM t1 ORDER BY (a+b) COLLATE nocase;
104236 ** The ability to use an output result-set column in the WHERE, GROUP BY,
104237 ** or HAVING clauses, or as part of a larger expression in the ORDER BY
104552 ** column in the FROM clause. This is used by the LIMIT and ORDER BY
104979 ** a SELECT statement. pE is a term in an ORDER BY or GROUP BY clause.
105015 ** ORDER BY of a compound SELECT. The expression has not been
105019 ** ORDER BY term is not an integer index into the result set. That
105033 Select *pSelect, /* The SELECT statement with the ORDER BY clause */
105034 Expr *pE /* The specific ORDER BY term */
105046 /* Resolve all names in the ORDER BY term expression
105061 /* Try to match the ORDER BY expression against an expression
105076 ** Generate an ORDER BY or GROUP BY term out-of-range error.
105086 "%r %s BY term out of range - should be "
105092 ** Analyze the ORDER BY clause in a compound SELECT statement. Modify
105093 ** each term of the ORDER BY clause is a constant integer between 1
105096 ** ORDER BY terms that are already an integer between 1 and N are
105097 ** unmodified. ORDER BY terms that are integers outside the range of
105098 ** 1 through N generate an error. ORDER BY terms that are expressions
105101 ** At the first match, the ORDER BY expression is transformed into
105108 Select *pSelect /* The SELECT statement containing the ORDER BY */
105120 sqlite3ErrorMsg(pParse, "too many terms in ORDER BY clause");
105160 ** column references within the ORDER BY expression as required. */
105173 /* Convert the ORDER BY term into an integer column number iCol,
105201 sqlite3ErrorMsg(pParse, "%r ORDER BY term does not match any "
105210 ** Check every term in the ORDER BY or GROUP BY clause pOrderBy of
105222 ExprList *pOrderBy, /* The ORDER BY or GROUP BY clause to be processed */
105232 sqlite3ErrorMsg(pParse, "too many terms in %s BY clause", zType);
105280 ** pOrderBy is an ORDER BY or GROUP BY clause in SELECT statement pSelect.
105300 ExprList *pOrderBy, /* An ORDER BY or GROUP BY clause to resolve */
105305 struct ExprList_item *pItem; /* A term of the ORDER BY clause */
105319 /* If an AS-name match is found, mark this ORDER BY column as being
105328 /* The ORDER BY term is an integer constant. Again, set the column
105339 /* Otherwise, treat the ORDER BY term as an ordinary expression */
105367 ExprList *pGroupBy; /* The GROUP BY clause */
105415 ** In this case the ORDER BY clause (p->pOrderBy) should be resolved
105465 /* If there are no aggregate functions in the result-set, and no GROUP BY
105521 /* The ORDER BY and GROUP BY clauses may not refer to terms in
105527 /* If this is a converted compound query, move the ORDER BY clause from
105529 ** within the ORDER BY clause has been transformed to an integer value.
105538 /* Process the ORDER BY clause for singleton SELECT statements.
105539 ** The ORDER BY clause for compounds SELECT statements is handled
105543 ** If there is an ORDER BY clause on a term of a compound-select other
105546 ** resolve those symbols on the incorrect ORDER BY for consistency.
105549 && isCompound<=nCompound /* Defer right-most ORDER BY of a compound */
105559 /* Resolve the GROUP BY clause. At the same time, make sure
105560 ** the GROUP BY clause does not contain aggregate functions.
105571 "the GROUP BY clause");
105590 /* Resolve the ORDER BY on a compound SELECT after all terms of
105632 ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY x;
105636 ** SELECT a+b AS x, c+d AS y FROM t1 ORDER BY a+b;
108160 /* Check if pExpr is identical to any GROUP BY term. If so, consider
108189 ** a "group". The requirement that the GROUP BY term must be BINARY
108193 ** GROUP BY be BINARY is stricter than necessary. It would also work
108195 ** sequence as the GROUP BY term, but that is much harder to check,
108198 ** GROUP BY to use the BINARY collating sequence.
108410 assert( p->pGroupBy==0 ); /* Has no GROUP BY clause */
116309 ** zSql1: SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx
116444 "SELECT idx,count(*) FROM %Q.sqlite_stat4 GROUP BY idx",
122474 ** Add an INDEXED BY or NOT INDEXED clause to the most recently added
123725 ** pSrc->a[0].pIndex Pointer to the INDEXED BY index, if there is one
123839 ExprList *pOrderBy, /* Optional ORDER BY clause */
123867 ** Generate an expression tree to implement the WHERE, ORDER BY,
123870 ** DELETE FROM table_wxyz WHERE a<5 ORDER BY a LIMIT 1;
123878 ExprList *pOrderBy, /* The ORDER BY clause. May be null */
123890 /* Check that there isn't an ORDER BY without a LIMIT clause.
123893 sqlite3ErrorMsg(pParse, "ORDER BY without LIMIT on %s", zStmtType);
123908 ** DELETE FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1
123911 ** SELECT rowid FROM table_a WHERE col1=1 ORDER BY col2 LIMIT 1 OFFSET 1
123978 ExprList *pOrderBy, /* ORDER BY clause. May be null */
129222 ** and there is no WHERE or LIMIT or GROUP BY or ORDER BY clauses, and
131432 return 0; /* SELECT may not have an ORDER BY clause */
131435 ** there is no ORDER BY, we will get an error. */
131437 return 0; /* SELECT may not have a GROUP BY clause */
137508 "SELECT*FROM\"%w\".%s ORDER BY rowid",
138234 u8 isTnct; /* 0: Not distinct. 1: DISTICT 2: DISTINCT and ORDER BY */
138242 ** the ORDER BY (or GROUP BY) clause of query is being coded.
138245 ** example, assuming there is no index that can be used for the ORDER BY,
138248 ** SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10;
138260 ExprList *pOrderBy; /* The ORDER BY (or GROUP BY clause) */
138261 int nOBSat; /* Number of ORDER BY terms satisfied by indices */
138337 ExprList *pGroupBy, /* the GROUP BY clause */
138339 ExprList *pOrderBy, /* the ORDER BY clause */
138899 SortCtx *pSort, /* Information about the ORDER BY clause */
138908 int nExpr = pSort->pOrderBy->nExpr; /* No. of ORDER BY terms */
138912 int nOBSat = pSort->nOBSat; /* ORDER BY terms to skip */
139207 ** statement with an ORDER BY that is not optimized by an index. It
139212 ** SELECT a, bigblob FROM t1 ORDER BY a LIMIT 10
139303 SortCtx *pSort, /* If not NULL, info on how to process ORDER BY */
139396 ** the ORDER BY clause (pSort->pOrderBy), set the associated
139397 ** iOrderByCol value to one more than the index of the ORDER BY
139591 ** ORDER BY in this case since the order of entries in the set
139778 ** If the ExprList is an ORDER BY or GROUP BY clause then the resulting
139834 ** where xxx is one of "DISTINCT", "ORDER BY" or "GROUP BY". Exactly which
139866 SortCtx *pSort, /* Information on the ORDER BY clause */
140730 ** with an ORDER BY clause. This function allocates and returns a KeyInfo
140731 ** structure suitable for implementing the ORDER BY.
140792 ** If the query has an ORDER BY, then entries in the Queue table are kept in
140793 ** ORDER BY order and the first entry is extracted for each cycle. Without
140794 ** an ORDER BY, the Queue table is just a FIFO.
140823 ExprList *pOrderBy; /* The ORDER BY clause */
140885 /* Detach the ORDER BY clause from the compound SELECT */
140972 ** (3) There is no ORDER BY clause
141064 /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only
141065 ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.
141107 /* Compound SELECTs that have an ORDER BY clause are handled separately.
141349 ** SELECT might also skip this part if it has no ORDER BY clause and
141562 ** is an ORDER BY clause.
141566 ** <selectA> <operator> <selectB> ORDER BY <orderbylist>
141569 ** is to code both <selectA> and <selectB> with the ORDER BY clause as
141684 ExprList *pOrderBy; /* The ORDER BY clause */
141685 int nOrderBy; /* Number of terms in the ORDER BY clause */
141686 u32 *aPermute; /* Mapping from ORDER BY terms to result set columns */
141697 /* Patch up the ORDER BY clause
141706 ** the ORDER BY clause covers every term of the result set. Add
141707 ** terms to the ORDER BY clause as necessary.
141731 ** collations to the ORDER BY clause terms so that when the subqueries
142347 ** (**) Was: "The outer query may not have a GROUP BY." This case
142375 ** (11) The subquery and the outer query may not both have ORDER BY clauses.
142389 ** use ORDER BY. (Ticket #2942) This used to not matter
142409 ** rules (11), (13) and (14), they may also contain ORDER BY,
142422 ** ORDER BY clause of the parent must be copies of a term returned
142429 ** an ORDER BY clause. Ticket #3773. We could relax this constraint
142430 ** somewhat by saying that the terms of the ORDER BY clause must
142451 ** function in the select list or ORDER BY clause, flattening
142674 ** followed by any ORDER BY, LIMIT and/or OFFSET clauses. This block
142675 ** creates N-1 copies of the parent query without any ORDER BY, LIMIT or
142688 ** ) WHERE a!=5 ORDER BY 1
142697 ** ORDER BY 1
142836 ** ORDER BY column expression is identical to the iOrderByCol'th
142839 ** zero them before transfering the ORDER BY clause.
143198 ** BY clause of all window function used by the sub-query. It is safe
143205 ** * that the window frame has a PARTITION BY clase.
143237 ** a GROUP BY clause. But such a HAVING clause is also harmless
143273 ** copies of expressions found in the PARTITION BY clause of
143393 ** *ppMinMax to be an ORDER BY clause to be used for the optimization
143493 ** INDEXED BY clause, then try to locate the specified index. If there
143520 ** Detect compound SELECT statements that use an ORDER BY clause with
143523 ** SELECT ... FROM t1 EXCEPT SELECT ... FROM t2 ORDER BY .. COLLATE ...
143528 ** ORDER BY ... COLLATE ...
143531 ** above that generates the code for a compound SELECT with an ORDER BY clause
143533 ** result columns as on the ORDER BY clause. See ticket
143538 ** there are COLLATE terms in the ORDER BY.
144089 /* Locate the index named by the INDEXED BY clause, if any. */
144699 ** SELECT * FROM <tables> WHERE a=? GROUP BY b HAVING b=? AND c=?
144703 ** SELECT * FROM <tables> WHERE a=? AND b=? GROUP BY b HAVING c=?
144706 ** entirely of constants and expressions that are also GROUP BY terms that
144784 ** * There is no WHERE or GROUP BY or HAVING clauses on the subqueries
144907 ExprList *pGroupBy; /* The GROUP BY clause. May be NULL */
144912 SortCtx sSort; /* Info on how to code the ORDER BY clause */
144915 ExprList *pMinMaxOrderBy = 0; /* Added ORDER BY for min/max queries */
144945 /* All of these destinations are also able to ignore the ORDER BY clause */
144948 SELECTTRACE(1,pParse,p, ("dropping superfluous ORDER BY:\n"));
145072 /* If a FROM-clause subquery has an ORDER BY clause that is not
145077 ** Beware of these cases where the ORDER BY clause may not be safely
145086 ** (5) The ORDER BY isn't going to accomplish anything because
145088 ** (a) The outer query has a different ORDER BY clause
145100 ("omit superfluous ORDER BY on %r FROM-clause subquery\n",i+1));
145109 ** and if the subquery contains an ORDER BY clause and if
145114 ** FROM (SELECT x FROM tab ORDER BY y LIMIT 10);
145123 ** SELECT x FROM (SELECT x FROM tab ORDER BY y LIMIT 10);
145383 /* If the query is DISTINCT with an ORDER BY but is not an aggregate, and
145384 ** if the select-list is the same as the ORDER BY list, then this query
145385 ** can be rewritten as a GROUP BY. In other words, this:
145387 ** SELECT DISTINCT xyz FROM ... ORDER BY xyz
145391 ** SELECT xyz FROM ... GROUP BY xyz ORDER BY xyz
145394 ** used for both the ORDER BY and DISTINCT processing. As originally
145396 ** BY and DISTINCT, and an index or separate temp-table for the other.
145415 SELECTTRACE(0x400,pParse,p,("Transform DISTINCT into GROUP BY:\n"));
145421 /* If there is an ORDER BY clause, then create an ephemeral index to
145488 /* No aggregate functions and no GROUP BY clause */
145561 /* This case when there exist aggregate functions or a GROUP BY clause
145564 int iAMem; /* First Mem address for storing current GROUP BY */
145565 int iBMem; /* First Mem address for previous GROUP BY */
145570 int groupBySort; /* Rows come from source in GROUP BY order */
145574 int orderByGrp = 0; /* True if the GROUP BY and ORDER BY are the same */
145577 ** GROUP BY clause.
145592 /* If there is both a GROUP BY and an ORDER BY clause and they are
145593 ** identical, then it may be possible to disable the ORDER BY clause
145594 ** on the grounds that the GROUP BY will cause elements to come out
145595 ** in the correct order. It also may not - the GROUP BY might use a
145598 ** ORDER BY and GROUP BY clauses are the same by setting the orderByGrp
145602 /* The GROUP BY processing doesn't care whether rows are delivered in
145604 ** So set the ASC/DESC flags in the GROUP BY to match those in the
145605 ** ORDER BY to maximize the chances of rows being delivered in an
145606 ** order that makes the ORDER BY redundant. */
145707 /* Processing for aggregates with GROUP BY is very different and
145708 ** much more complex than aggregates without a GROUP BY.
145737 /* If there is a GROUP BY clause we might need a sorting index to
145749 /* Initialize memory locations used by GROUP BY aggregate processing
145765 /* Begin a loop that will extract all source rows in GROUP BY order.
145801 "DISTINCT" : "GROUP BY");
145836 VdbeComment((v, "GROUP BY sort")); VdbeCoverage(v);
145840 /* If the index or temporary table used by the GROUP BY sort
145841 ** will naturally deliver rows in the order required by the ORDER BY
145854 /* Evaluate the current GROUP BY terms and store in b0, b1, b2...
145856 ** Then compare the current GROUP BY terms against the GROUP BY terms
145877 /* Generate code that runs whenever the GROUP BY changes.
145878 ** Changes in the GROUP BY are detected by the previous code
145884 ** for the next GROUP BY batch.
145960 } /* endif pGroupBy. Begin aggregate queries without GROUP BY: */
146055 /* This case runs if the aggregate has no GROUP BY clause. The
146065 ** be an appropriate ORDER BY expression for the optimization.
146108 /* If there is an ORDER BY clause, then we need to sort the results
146113 sSort.nOBSat>0 ? "RIGHT PART OF ORDER BY":"ORDER BY");
148003 ** GROUP BY <other-columns>
148004 ** ORDER BY pOrderBy LIMIT pLimit
148006 ** If pTab is a view, the GROUP BY clause is omitted.
148034 ExprList *pOrderBy, /* ORDER BY clause */
148052 sqlite3ErrorMsg(pParse, "ORDER BY without LIMIT on UPDATE");
148130 ExprList *pOrderBy, /* ORDER BY clause. May be null */
151423 ** one corresponding WhereLoop object (unless INDEXED BY constraints
151457 i8 isOrdered; /* True if satisfies ORDER BY */
151514 Bitmask revLoop; /* aLoop[]s that should be reversed for ORDER BY */
151518 i8 isOrdered; /* No. of ORDER BY terms satisfied. -1 for unknown */
151771 ExprList *pOrderBy; /* The ORDER BY clause or NULL */
151784 i8 nOBSat; /* Number of ORDER BY terms satisfied by indices */
151796 Bitmask revMask; /* Mask of ORDER BY terms that need reversing */
152446 /* If the SELECT statement has an ORDER BY clause, zero the
152448 ** ORDER BY term exactly matches one of the terms of the
153625 ** to force the output order to conform to an ORDER BY.
156294 ** 5. The ORDER BY clause, if any, will be made available to the xBestIndex
156612 ** Return the number of ORDER BY terms that are satisfied by the
156614 ** completely sorted. A return equal to the number of ORDER BY
156616 ** is positive but less than the number of ORDER BY terms means that
156624 ** In the ORDER BY LIMIT optimization, if the inner-most loop is known
156635 ** If the ORDER BY LIMIT optimization applies, the jump destination should
156636 ** be the continuation for the second-inner-most loop. If the ORDER BY
156649 /* The ORDER BY LIMIT optimization does not apply. Jump to the
157772 /* If the ORDER BY clause contains only columns in the current
157783 /* Skip over constant terms in the ORDER BY clause */
159729 ** implementing the ORDER BY clause in pBuilder.
159731 ** Return False if pBuilder does not contain an ORDER BY clause or
159733 ** ORDER BY clause.
159953 /* An INDEXED BY clause specifies a particular index to use */
159958 /* There is no INDEXED BY clause. Create a fake Index object in local
159989 && !pSrc->fg.isIndexedBy /* Has no INDEXED BY clause */
160039 /* Loop over all indices. If there was an INDEXED BY clause, then only
160065 /* The ONEPASS_DESIRED flags never occurs together with ORDER BY */
160332 ** consume the ORDER BY clause because (1) the order of IN terms
160485 ** Return true if ORDER BY clause may be handled as DISTINCT.
160889 ** parameters) to see if it outputs rows in the requested ORDER BY
160890 ** (or GROUP BY) without requiring a separate sort operation. Return N:
160892 ** N>0: N terms of the ORDER BY clause are satisfied
160893 ** N==0: No terms of the ORDER BY clause are satisfied
160894 ** N<0: Unknown yet how many terms of ORDER BY might be satisfied.
160897 ** strict. With GROUP BY and DISTINCT the only requirement is that
160898 ** equivalent rows appear immediately adjacent to one another. GROUP BY
160900 ** as equivalent rows are grouped together. Thus for GROUP BY and DISTINCT
160901 ** the pOrderBy terms can be matched in any order. With ORDER BY, the
160906 ExprList *pOrderBy, /* ORDER BY or GROUP BY or DISTINCT clause to check */
160918 u8 isMatch; /* iColumn matches a term of the ORDER BY clause */
160922 u16 nOrderBy; /* Number terms in the ORDER BY clause */
160929 Expr *pOBExpr; /* An expression from the ORDER BY clause */
160930 CollSeq *pColl; /* COLLATE function from an ORDER BY clause term */
160933 Bitmask obSat = 0; /* Mask of ORDER BY terms satisfied so far */
160934 Bitmask obDone; /* Mask of all ORDER BY terms */
160947 ** that WhereLoop that are in the ORDER BY clause are different for every
160949 ** order-distinct. A WhereLoop that has no columns in the ORDER BY clause
160956 ** rowid appears in the ORDER BY clause, the corresponding WhereLoop is
160994 /* Mark off any ORDER BY term X that is a column in the table of
161009 /* IN terms are only valid for sorting in the ORDER BY LIMIT
161057 u8 bOnce = 1; /* True to run the ORDER BY search loop */
161075 ** considered to match an ORDER BY term.
161128 /* Find the ORDER BY term that corresponds to the j-th column
161129 ** of the index and mark that ORDER BY term off
161160 /* Make sure the sort order is compatible in an ORDER BY clause.
161161 ** Sort order is irrelevant for a GROUP BY clause. */
161202 /* Mark off any other ORDER BY terms that reference pLoop */
161233 ** BY clause - and so any order that groups rows as required satisfies the
161250 ** SELECT * FROM t1 GROUP BY x,y ORDER BY x,y; -- IsSorted()==1
161251 ** SELECT * FROM t1 GROUP BY y,x ORDER BY y,x; -- IsSorted()==0
161336 int nOrderBy; /* Number of ORDER BY clause terms */
161359 /* If nRowEst is zero and there is an ORDER BY clause, ignore it. In this
161383 /* If there is an ORDER BY clause and it is not being ignored, set up
161387 ** the ORDER BY clause are already in order, where X is the array
162156 ** ORDER BY CLAUSE PROCESSING
162158 ** pOrderBy is a pointer to the ORDER BY clause (or the GROUP BY clause
162160 ** if there is one. If there is no ORDER BY clause or if this routine
162175 ExprList *pOrderBy, /* An ORDER BY (or GROUP BY) clause, or NULL */
162209 /* An ORDER/GROUP BY clause of more than 63 terms cannot be optimized */
162360 /* Try to ORDER BY the result set to make distinct processing easier */
162695 ** the output order. So omit any ORDER BY/GROUP BY elimination
163147 ** either the select list or ORDER BY clause (the only two places window
163156 ** SELECT a+1, max(b) OVER (PARTITION BY c ORDER BY d) FROM t1 ORDER BY e;
163160 ** SELECT a+1, max(b) OVER (PARTITION BY c ORDER BY d) FROM (
163161 ** SELECT a, e, c, d, b FROM t1 ORDER BY c, d
163162 ** ) ORDER BY e;
163169 ** * FROM, WHERE, GROUP BY and HAVING clauses are all moved to
163172 ** * ORDER BY, LIMIT and OFFSET remain part of the parent query.
163175 ** select-list and ORDER BY expressions in the parent query are
163183 ** SELECT max(b) OVER (PARTITION BY c ORDER BY d),
163184 ** min(e) OVER (PARTITION BY c ORDER BY d)
163189 ** SELECT max(b) OVER (PARTITION BY c ORDER BY d),
163190 ** min(e) OVER (PARTITION BY a ORDER BY b)
163195 ** SELECT max(b) OVER (PARTITION BY c ORDER BY d) FROM (
163196 ** SELECT e, min(e) OVER (PARTITION BY a ORDER BY b), c, d, b FROM
163197 ** SELECT a, e, c, d, b FROM t1 ORDER BY a, b
163198 ** ) ORDER BY c, d
163199 ** ) ORDER BY e;
163810 "RANGE with offset PRECEDING/FOLLOWING requires one ORDER BY expression"
164126 /* Create the ORDER BY clause for the sub-select. This is the concatenation
164127 ** of the window PARTITION and ORDER BY clauses. Then, if this makes it
164128 ** redundant, remove the ORDER BY from the parent SELECT. */
164151 /* Append the PARTITION BY and ORDER BY expressions to the to the
164183 /* If there is no ORDER BY or PARTITION BY clause, and the window
164235 ** result-set or ORDER BY clause of the SELECT statement p. */
164370 ** Attach PARTITION and ORDER BY clauses pPartition and pOrderBy to window
164411 zErr = "ORDER BY clause";
164525 /* Allocate registers to use for PARTITION BY values, if any. Initialize
164699 ** (ORDER BY a, b GROUPS BETWEEN 2 PRECEDING AND 2 FOLLOWING)
165200 ** the ORDER BY term in the window, and that argument op is OP_Ge, it generates
165208 ** If the sort-order for the ORDER BY term in the window is DESC, then the
165230 ExprList *pOrderBy = p->pMWin->pOrderBy; /* ORDER BY clause for window */
165259 /* If the BIGNULL flag is set for the ORDER BY, then it is required to
165832 ** In the above notation, "csr.key" means the current value of the ORDER BY
166007 ** registers to store copies of the ORDER BY expressions (peer values)
166320 ** Issue an error message if an ORDER BY or LIMIT clause occurs on an
166329 sqlite3ErrorMsg(pParse, "syntax error near \"ORDER BY\"");
166358 pLoop->pOrderBy!=0 ? "ORDER BY" : "LIMIT",
167488 59, /* BY => ID */
167761 /* 34 */ "BY",
168183 /* 130 */ "indexed_by ::= INDEXED BY nm",
168186 /* 133 */ "orderby_opt ::= ORDER BY sortlist",
168196 /* 143 */ "groupby_opt ::= GROUP BY nexprlist",
168324 /* 271 */ "tridxby ::= INDEXED BY nm",
168367 /* 314 */ "window ::= PARTITION BY nexprlist orderby_opt frame_opt",
168368 /* 315 */ "window ::= nm PARTITION BY nexprlist orderby_opt frame_opt",
168369 /* 316 */ "window ::= ORDER BY sortlist frame_opt",
168370 /* 317 */ "window ::= nm ORDER BY sortlist frame_opt",
169094 260, /* (130) indexed_by ::= INDEXED BY nm */
169097 249, /* (133) orderby_opt ::= ORDER BY sortlist */
169107 247, /* (143) groupby_opt ::= GROUP BY nexprlist */
169235 293, /* (271) tridxby ::= INDEXED BY nm */
169278 308, /* (314) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
169279 308, /* (315) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
169280 308, /* (316) window ::= ORDER BY sortlist frame_opt */
169281 308, /* (317) window ::= nm ORDER BY sortlist frame_opt */
169504 -3, /* (130) indexed_by ::= INDEXED BY nm */
169507 -3, /* (133) orderby_opt ::= ORDER BY sortlist */
169517 -3, /* (143) groupby_opt ::= GROUP BY nexprlist */
169645 -3, /* (271) tridxby ::= INDEXED BY nm */
169688 -5, /* (314) window ::= PARTITION BY nexprlist orderby_opt frame_opt */
169689 -6, /* (315) window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
169690 -4, /* (316) window ::= ORDER BY sortlist frame_opt */
169691 -5, /* (317) window ::= nm ORDER BY sortlist frame_opt */
170370 case 130: /* indexed_by ::= INDEXED BY nm */
170376 case 133: /* orderby_opt ::= ORDER BY sortlist */
170377 case 143: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==143);
170971 case 271: /* tridxby ::= INDEXED BY nm */
170974 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
171148 case 314: /* window ::= PARTITION BY nexprlist orderby_opt frame_opt */
171153 case 315: /* window ::= nm PARTITION BY nexprlist orderby_opt frame_opt */
171159 case 316: /* window ::= ORDER BY sortlist frame_opt */
171164 case 317: /* window ::= nm ORDER BY sortlist frame_opt */
172087 ** 98: BY RENAME
172284 testcase( i==143 ); /* BY */
183026 "SELECT %s WHERE rowid BETWEEN %lld AND %lld ORDER BY rowid %s",
183031 zSql = sqlite3_mprintf("SELECT %s ORDER BY rowid %s",
185907 ** xBestIndex - Analyze a WHERE and ORDER BY clause.
185922 /* This vtab delivers always results in "ORDER BY term ASC" order. */
189658 ** xBestIndex - Analyze a WHERE and ORDER BY clause.
190196 "FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC",
190199 "ORDER BY level DESC, idx ASC",
190224 " GROUP BY level HAVING cnt>=?"
190225 " ORDER BY (level %% 1024) ASC, 2 DESC LIMIT 1",
190232 " WHERE level = ? ORDER BY idx ASC LIMIT ?"
190263 /* 35 */ "SELECT idx FROM %Q.'%q_segdir' WHERE level=? ORDER BY 1 ASC",
190272 "ORDER BY level DESC, idx ASC",
190499 /* "SELECT * FROM %_segdir WHERE level BETWEEN ? AND ? ORDER BY ..." */
190508 /* "SELECT * FROM %_segdir WHERE level = ? ORDER BY ..." */
209799 "ORDER BY name"
210337 "SELECT %s FROM \"%s%w\" ORDER BY %s LIMIT 1",
210435 sqlite3_mprintf("SELECT %s FROM \"rbu_imp_%w\" ORDER BY %s LIMIT 1",
211201 "SELECT %s, 0 AS rbu_control FROM '%q' %s %s %s ORDER BY %s%s",
211213 "SELECT %s, rbu_control FROM %s.'rbu_tmp_%q' %s ORDER BY %s%s",
211223 "ORDER BY %s%s",
211364 (zOrder ? "ORDER BY" : ""), zOrder,
212419 " ORDER BY type DESC"
214966 sqlite3_str_appendf(pSql, " ORDER BY name");
221492 ** ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid
222571 #define FTS5_STMT_SCAN_ASC 0 /* SELECT rowid, * FROM ... ORDER BY 1 ASC */
222572 #define FTS5_STMT_SCAN_DESC 1 /* SELECT rowid, * FROM ... ORDER BY 1 DESC */
227422 ** the maximum rowid. Or, if the iterator is "ORDER BY rowid DESC", then it
231532 int bRev, /* True for ORDER BY ASC */
232418 "segid=? AND term<=? ORDER BY term DESC LIMIT 1",
235207 int bDesc, /* True for "ORDER BY rowid DESC" */
236100 "ORDER BY 1, 2",
236960 ** SELECT rowid, <fts> FROM <fts> ORDER BY +rank;
237003 int bDesc; /* True for "ORDER BY rowid DESC" queries */
237008 Fts5Sorter *pSorter; /* Sorter for "ORDER BY rank" queries */
237277 #define FTS5_PLAN_SORTED_MATCH 4 /* (<tbl> MATCH ? ORDER BY rank) */
237325 ** Within the ORDER BY, the following are supported:
237327 ** 5. ORDER BY rank [ASC|DESC]
237328 ** 6. ORDER BY rowid [ASC|DESC]
237332 ** flags used to encode the ORDER BY clause:
237373 ** Costs are not modified by the ORDER BY clause.
237478 /* Set idxFlags flags for the ORDER BY clause */
237836 "SELECT rowid, rank FROM %Q.%Q ORDER BY %s(\"%w\"%s%s) %s",
238044 int bDesc; /* True if ORDER BY [rank|rowid] DESC */
238045 int bOrderByRank; /* True if ORDER BY rank */
238162 ** processing for a "... MATCH <expr> ORDER BY rank" query (ePlan is
239828 "SELECT %s FROM %s T WHERE T.%Q >= ? AND T.%Q <= ? ORDER BY T.%Q ASC",
239829 "SELECT %s FROM %s T WHERE T.%Q <= ? AND T.%Q >= ? ORDER BY T.%Q DESC",
243773 ** specifically - "ORDER BY term" or "ORDER BY term ASC" - set the