import { BaseScalar, Scalar } from '../../scalar'; import { AsScalarType, InputObject, RowObject } from '../../types'; import { Star } from '../../object/star'; import type { Condition } from '../../condition'; import { XExpression, Expression, ValuedSelect } from '../../expression'; import { XWithSelect, XNamedSelect } from '../../rowset'; import { STATEMENT_KIND, STATEMENT_TAG } from '../statement'; import { Fromable } from './common/fromable'; import { SelectColumn } from './select-column'; import { Sort, SortObject } from './sort'; import { Union } from './union'; /** * SELECT查询,传入的表达式会被自动命名为 '#column_' + i; */ export declare class Select extends Fromable { $top?: number; $offset?: number; $limit?: number; $distinct?: boolean; $columns: (SelectColumn | Star)[]; $sorts?: Sort[]; $groups?: Expression[]; $having?: Condition; $union?: Union; $tag: STATEMENT_TAG.EXECUTABLE; readonly $kind: STATEMENT_KIND.SELECT; constructor(...columns: (BaseScalar | Expression | SelectColumn | Star)[] | [results: InputObject]); /** * 去除重复的 */ distinct(): this; /** * TOP * @param rows 行数 */ top(rows: number): this; /** * order by 排序 * @param sorts 排序信息 */ orderBy(sorts: Sort[] | SortObject): this; orderBy(...sorts: Sort[]): this; /** * 分组查询 * @param groups */ groupBy(...groups: XExpression[]): this; /** * Having 子句 * @param condition */ having(condition: Condition): this; /** * 偏移数 * @param rows */ offset(rows: number): this; /** * 限定数 * @param rows */ limit(rows: number): this; /** * 合并查询 */ union(select: Select, all?: boolean): this; unionAll(select: Select): this; /** * 将本次查询,转换为Table行集 * @param alias */ as(alias: TAlias): XNamedSelect; asWith(name: N): XWithSelect; /** * 将本次查询结果转换为值 */ asValue>(): ValuedSelect; asColumn(name: N): SelectColumn, N>; static isSelect(object: any): object is Select; }