SELECT to_date(
(
SELECT MAX(TO_CHAR(from_tz(cast(CREATE_UTC_DATETIME AS TIMESTAMP), 'UTC') AT TIME ZONE 'Asia/Tehran', 'YYYY-MM-DD')) GROUP_DATE
FROM REPORT_EVENTS
), 'yyyy-mm-dd') - (ROWNUM * 7) group_date
FROM (SELECT 1 counter
FROM dual
CONNECT BY LEVEL <= 52
)
答案 0 :(得分:1)
您可以使用selectRaw()
和DB::raw()
来处理复杂的SQL语句
YourModel::selectRaw("to_date(("
. "SELECT MAX(TO_CHAR(from_tz(cast(CREATE_UTC_DATETIME AS TIMESTAMP), 'UTC') AT TIME ZONE 'Asia/Tehran', 'YYYY-MM-DD')) GROUP_DATE "
. "FROM REPORT_EVENTS), 'yyyy-mm-dd') - (ROWNUM * 7) group_date")
->from(DB::raw("SELECT 1 counter FROM dual CONNECT BY LEVEL <= 52"));