Help using oracle Analytical function.

pts.
Tags:
Microsoft Windows
Oracle
SQL
I am trying to create a query that will do two parallel select from the data available. I want to write one select statement using analytical functions, What I want to do is as follows: I one single query I want to find out the count of the transactions in the last 7 days from sysdate and last 6 months from sysdate. The table has got transactions and the corresponding dates. I am new with the analytical functions and finding it difficult to understand the use of the 'order' and 'range' options. It will be great if someone can write the above query with an explanation how it works. Thanks

Answer Wiki

Thanks. We'll let you know when a new response is added.

If you want to use a RANGE windowing clause, you would need something like this:

    COUNT(*) OVER (ORDER BY trans_date RANGE 7 PRECEDING) AS last_7_days,
    COUNT(*) OVER (ORDER BY trans_date RANGE 180 PRECEDING) AS last_180_days

Recommended read: Understanding Analytic Functions in Oracle SQL

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Help using oracle Analytical function (Q/A) | Seek The Sun Slowly
    [...] Original Address: http://itknowledgeexchange.techtarget.com/itanswers/help-using-oracle-analytical-function/ (0) Comments Read [...]
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: