如何从当前月份每隔1./2./3./4-5周(间隔)选择一次?
所以不像:
select to_char(sysdate,'W') from dual但我需要一个间隔=当月的一周(例如,oktober的2周,因为现在是10月- sysdate)。因此,具体而言:
select SUM(number)/((trunc(sysdate,'WW')/4) from my_table where date between ? and ? 发布于 2018-10-29 11:57:26
像这样的东西应该对你有用。
SELECT TO_CHAR(datecol,'W') AS week,
SUM(countcol) AS sum_of_sales
FROM sales
WHERE TO_CHAR(datecol,'YYYYMM') = TO_CHAR(SYSDATE,'YYYYMM') --current year and month.
GROUP BY TO_CHAR(datecol,'W')
ORDER BY TO_CHAR(datecol,'W')https://stackoverflow.com/questions/53044468
复制相似问题