public void RenderGroupByClauses() { Column column1 = new Column("Column1"); Column column2 = new Column("Column2"); GroupByClause groupByClause1 = new GroupByClause(column1); GroupByClause groupByClause2 = new GroupByClause(column2); GroupByClauses groupByClauses = new GroupByClauses(groupByClause1, groupByClause2); Assert.AreEqual("[Column1], [Column2]", sqlClientRenderer.Render(groupByClauses)); }
public override string Compile(SqlResult ctx) { // percentile_cont(0.9) within group (order by "value") over (partition by ...) var column = new Column { Name = Column }.Compile(ctx); var partition = String.Join(", ", GroupByClauses.Select(clause => clause.Compile(ctx))); partition = partition.Length > 0 ? "PARTITION BY " + partition : ""; return($"PERCENTILE_CONT({Percentile}) WITHIN GROUP(ORDER BY {column}) OVER({partition}) {ctx.Compiler.ColumnAsKeyword}{ctx.Compiler.WrapValue(Alias ?? Type)}"); }
public void CreateOrderByClauses() { Column column1 = new Column("Column1"); Column column2 = new Column("Column2"); GroupByClause groupByClause1 = new GroupByClause(column1); GroupByClause groupByClause2 = new GroupByClause(column2); GroupByClauses groupByClauses = new GroupByClauses(groupByClause1, groupByClause2); Assert.AreEqual(groupByClause1, groupByClauses.LeftClause); Assert.AreEqual(groupByClause2, groupByClauses.RightClause); }
public override string Render(GroupByClauses groupByClauses) { if (groupByClauses.LeftClause == null) { return(groupByClauses.RightClause.Render(this)); } else if (groupByClauses.RightClause == null) { return(groupByClauses.LeftClause.Render(this)); } else { return(string.Format("{0}, {1}", groupByClauses.LeftClause.Render(this), groupByClauses.RightClause.Render(this))); } }
public abstract string Render(GroupByClauses groupByClauses);