我有一个查询,必须提取必须在1个月前付款的付款图表。例如,它必须获得付款日期为2017.12.04(发布日期)和更早的行,但它也会获得12月17日,10日等的数据。这是一个查询
select CONTRACT_ID
from PaymentGraph
where date(now()) >= date_sub(PAYMENT_DATE, interval DAY(LAST_DAY(now())) day)
and state = 'A'
and ifnull(paid, 0) < amount
我不知道它为什么会这样运作,有人可以说可能是什么问题吗?
答案 0 :(得分:2)
看起来你的日期比较有点复杂,你可以稍微写一点试试这个:
Select drpCountry = new Select(driver.findElement(By.id("j_companyname")));
drpCountry.selectByVisibleText("ES188CLIENT16");
// these also can help you
//drpCountry.selectByIndex("givenindex");
//drpCountry.selectByValue("ES188CLIENT16");
答案 1 :(得分:2)
试试这个
select CONTRACT_ID
from PaymentGraph
where PAYMENT_DATE <= DATE_ADD(curdate(),INTERVAL -1 MONTH)
and state = 'A'
and (paid < amount or paid is null)
这个解决方案在所有属性都是SARGable的意义上是好的,因此可以充分利用PaymentGraph(PAYMENT_DATE, state, paid)
之类的索引