public String formSelect(String tableName, String subQuery, List<String> orderBys, long limit, long offset) {
boolean needLimit = limit != -1;
boolean needOffset = offset != -1;
if(needOffset && (orderBys == null || orderBys.isEmpty())) {
throw new DBException("MSSQL offset queries require an order by column.");
}
boolean keepSelect = false;
StringBuilder fullQuery = new StringBuilder();
if (needOffset) {