@Override
    public String getQuerySQL() {
        SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yy", Locale.US);
        if (beginDate!=null || endDate!=null || lastNum!=null) {
            return "select P.ID, P.REGNUM, P.ID_TYPE, P.BEGINDATE, PT.GROUPTYPE, PT.TYPE " +
                    "from DPS$PACKAGE P, DPS$PACKAGETYPE PT " +
                    "WHERE PT.ID=P.ID_TYPE " +
                    (beginDate==null?"":" AND TRUNC(BEGINDATE) >= '" + dateFormat.format(beginDate) + "' ") +
                    (endDate==null?"":" AND TRUNC(BEGINDATE) <= '" + dateFormat.format(endDate) + "' ") +
                    (lastNum==null?"":" AND NUM > " + lastNum.toString()) +
                    " ORDER BY NUM";
         } else {
            return "select P.ID, P.REGNUM, P.ID_TYPE, P.BEGINDATE, PT.GROUPTYPE, PT.TYPE " +
                    "from DPS$PACKAGE P, DPS$PACKAGETYPE PT " +
                    "WHERE PT.ID=P.ID_TYPE";
        }
    }