SELECT * FROM XIAOHAO where ${ IF(AND(aa >= YEAR(aa) + "-" + "01-01",aa <= YEAR(aa) + "-" + "01-29"),
"and createdate<='"+aa+"'"+"and yuefen='"+YEAR(aa) + "-" + "01"+ "'",
IF(AND(aa >= YEAR(aa) + "-" + "01-30", aa <= IF(YEAR(aa) % 400 = 0, YEAR(aa) + "-" + "02-27", IF(YEAR(aa) % 4 = 0, YEAR(aa) + "-" + "02-27", YEAR(aa) + "-" + "02-26"))),
"and createdate<='"+aa+"'"+"and yuefen='"+YEAR(aa) + "-" + "02"+ "'",
IF(AND(aa > IF(YEAR(aa) % 400 = 0, YEAR(aa) + "-" + "02-27", IF(YEAR(aa) % 4 = 0, YEAR(aa) + "-" + "02-27", YEAR(aa) + "-" + "02-26")), aa <= YEAR(aa) + "-" + "03-29"), "and createdate<='"+aa+"'"+"and yuefen='"+YEAR(aa) + "-" + "03"+ "'",
IF(AND(aa >= YEAR(aa) + "-" + "03-30", aa <= YEAR(aa) + "-" + "04-28"), "and createdate<='"+aa+"'"+"and yuefen='"+YEAR(aa) + "-" + "04"+ "'", IF(AND(aa >= YEAR(aa) + "-" + "04-29", aa <= YEAR(aa) + "-" + "05-29"), "and createdate<='"+aa+"'"+"and yuefen='"+YEAR(aa) + "-" + "05"+ "'", IF(AND(aa >= YEAR(aa) + "-" + "05-30", aa <= YEAR(aa) + "-" + "06-28"), "and createdate<='"+aa+"'"+"and yuefen='"+YEAR(aa) + "-" + "06"+ "'", IF(AND(aa >= YEAR(aa) + "-" + "06-29", aa <= YEAR(aa) + "-" + "07-29"), "and createdate<='"+aa+"'"+"and yuefen='"+YEAR(aa) + "-" + "07"+ "'", IF(AND(aa >= YEAR(aa) + "-" + "07-30", aa <= YEAR(aa) + "-" + "08-29"),"and createdate<='"+aa+"'"+"and yuefen='"+YEAR(aa) + "-" + "08"+ "'", IF(AND(aa >= YEAR(aa) + "-" + "08-30", aa <= YEAR(aa) + "-" + "09-28"),"and createdate<='"+aa+"'"+"and yuefen='"+YEAR(aa) + "-" + "09"+ "'", IF(AND(aa >= YEAR(aa) + "-" + "09-29", aa <= YEAR(aa) + "-" + "10-29"), "and createdate<='"+aa+"'"+"and yuefen='"+YEAR(aa) + "-" + "10"+ "'", IF(AND(aa >= YEAR(aa) + "-" + "10-29", aa <= YEAR(aa) + "-" + "11-28"), "and createdate<='"+aa+"'"+"and yuefen='"+YEAR(aa) + "-" + "11"+ "'", IF(AND(aa >= YEAR(aa) + "-" + "11-29", aa <= YEAR(aa) + "-" + "12-31"), "and createdate<='"+aa+"'"+"and yuefen='"+YEAR(aa) + "-" + "12"+ "'", 100))))))))))))
} order by createdate |