Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Counting Multiple Occurences in Same Table Grouped by Date

Brent Grech-OracleDec 31 2012 — edited Dec 31 2012
Hello,

I am stuck on this one. I have a table that has many transactions. I would like to write a SQL that shows for a given date range, how many rows were added and how many were distinctly updated. In my table I have 2 timestamp columns that I am trying to count on:

DATE_CREATED
LAST_UPDATE_DATE

I would like my report to look something like. I don't care if the updated column includes the rows created but I do care if there are no rows created and would like to set the value to 0.


Date Number Rows Created Number of Rows Updated
12/01/2013 10 15
12/02/2013 0 10
12/03/2013 30 36
12/04/2013 50 70
...

I cannot figure this out. I know it's a combination of CASE statements and am hoping to get it done with regular SQL

I transform the timestamp with TO_CHAR to MM/DD/YYYY then group by. I have no problem getting one or the other with separate queries, but not both in the same table.

Thank you!
-Brent
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 28 2013
Added on Dec 31 2012
2 comments
1,059 views