
JCRQ in this picture is the 2019-08-01 -- -- -- -- -- - 2019-08-01, I want to be the end of this month every 7 days for a sum (JLJE) calculation results, the approximate values like this:
800 500 400 200 100
What a great god will deal with it, a great god, please give an example for the younger brother study research, thank you, seek the great spirit of advice,
CodePudding user response:
Group by trunc (to_char (JCRQ, 'dd')/7)CodePudding user response:
Don't quite understand what you said every seven days polymerization time what do you meanCodePudding user response:
SELECT SUM (JLJE),CASE
The WHEN TO_CHAR (SYSDATE, 'DD') BETWEEN '01' AND '07' THEN 1
The WHEN TO_CHAR (SYSDATE, 'DD') BETWEEN '08' AND '14' THEN 2
The WHEN TO_CHAR (SYSDATE, 'DD') BETWEEN the '15' AND '21' THEN 3
The WHEN TO_CHAR (SYSDATE, 'DD') BETWEEN '22' AND '28' THEN 4
The ELSE 5
END
The FROM TABLE_NAME JCRQ
GROUP BY
CASE
The WHEN TO_CHAR (SYSDATE, 'DD') BETWEEN '01' AND '07' THEN 1
The WHEN TO_CHAR (SYSDATE, 'DD') BETWEEN '08' AND '14' THEN 2
The WHEN TO_CHAR (SYSDATE, 'DD') BETWEEN the '15' AND '21' THEN 3
The WHEN TO_CHAR (SYSDATE, 'DD') BETWEEN '22' AND '28' THEN 4
The ELSE 5
The END;