oracle sql query

I need to write a query that will return the table_name, and the difference in number of rows i.e the difference between the maximum and minimum rows recorded for the table which would be from the maxium and minumium dates for the rows - it can be assumed the minimum dates is the minium rows etc

my table columns are:

table_name, monitor_date, num_rows


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
I do not understand the question.

Are you saying you have a lookup type table that tells you how many rows should in in a different table?

I do not understand what defines the min and max rows of a table based on some date.
is this what you mean?

SELECT table_name, min_value, max_value, max_value - min_value difference
               OVER (PARTITION BY table_name
                     ORDER BY monitor_date
               OVER (PARTITION BY table_name
                     ORDER BY monitor_date
          FROM your_table)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
or,  even simpler,  if you can reliably assume that your num_rows will grow over time then you don't really need to include the time component at all.

SELECT   table_name,
         MIN(num_rows) min_value,
         MAX(num_rows) max_value,
         MAX(num_rows) - MIN(num_rows) difference
    FROM your_table
GROUP BY table_name

but, again, this assumes the table starts small and the number of rows never decreases, only constant or increasing.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

awking00Information Technology SpecialistCommented:
Worse yet, it assumes ALL tables never delete any rows. Are you sure that occurs?
>>> it assumes ALL tables never delete any rows.

no it didn't,  because the group by/partition by makes the values table specific
awking00Information Technology SpecialistCommented:
I was referring to the possibility that num_rows may not reliably grow over time for any table.
well, that was already mentioned as one of the assumptions

the first query compares the earliest count with the latest count, whether they are truly the smallest and biggest or not.

the second query compares the smallest and biggest counts whether they are truly the earliest and latest or not.

I can't think of any other combintion of early/late, small/big that would have any meaning with with sample structure given.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.