IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

To get the count of rows for every 1 hour of timestamp range


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Chidane

New User


Joined: 25 Nov 2021
Posts: 18
Location: India

PostPosted: Sat Feb 17, 2024 8:00 pm
Reply with quote

Hi Team,

Could you please help me with the following requirement.
I would like to get the count of number of rows from TABLE_A for every 1 hour of timestamp range.

The below query gives count of rows for the whole day.
I would like to know the count of rows of every 1 hour in this timestamp range. That means I should get 24 entries.

Code:
SELECT COUNT(*) FROM TABLE_A WHERE TSTAMP BETWEEN
'2024-02-01-00.00.00.000001' AND '2024-02-02-00.00.00.000001'


Could you please help me here to achieve this.

Thanks
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3066
Location: NYC,USA

PostPosted: Sat Feb 17, 2024 8:24 pm
Reply with quote

Set up job to run every one hour using scheduling and ftp the couns.
Back to top
View user's profile Send private message
Chidane

New User


Joined: 25 Nov 2021
Posts: 18
Location: India

PostPosted: Sat Feb 17, 2024 8:49 pm
Reply with quote

We wil be setting up the job every 1 hour to get the details from table. But before that we would like to know the count of rows for every 1 hour as part of aalysis purpose.

We can manually change the hour in SQL query and run it 24 times. However requesting to check whether in single query run, whether we can get the requested details (count of rows that got updated every 1 hour of given timestamp of a day).
Back to top
View user's profile Send private message
Chidane

New User


Joined: 25 Nov 2021
Posts: 18
Location: India

PostPosted: Mon Feb 19, 2024 5:38 pm
Reply with quote

Any help is appreciated, please.

Thanks
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Insert header record with record coun... DFSORT/ICETOOL 14
Search our Forums:

Back to Top