private void includeRegDate(SQLStringBuilder queryString, bool filterByDate) { var subQuery = new SQLStringBuilder(); subQuery.Scope("Registration Dates", () => { string[] subColumns = { "learnerKey", "MIN(regDate) as theRegDate" }; subQuery.Select(subColumns); subQuery.From("enrollments"); subQuery.GroupBy("learnerKey"); if (filterByDate) { filterHavingByDate(subQuery); } }); if (filterByDate) { queryString.RightJoin(String.Format("{0} as e", subQuery.ToString()), "e.LearnerKey = ld.LearnerKey"); } else { queryString.LeftJoin(String.Format("{0} as e", subQuery.ToString()), "e.LearnerKey = ld.LearnerKey"); } }
private static void groupByDivision(SQLStringBuilder queryString) { queryString.GroupBy("division"); }