Need 1 row returned based on most-recent date, OnBase document cleanup

I am trying to cleanup an application’s reports and archived reports. Hyland’s OnBase is our archiving solution. I am trying to determine the most-recent date on which any ItemNum was viewed. Determining the most-recent date that a report type was viewed can help me determine if any of these 400+ reports are useful, or if they can be disabled.

Some important columns:

  • ItemTypeGroupNum – The application’s report section in Onbase
  • ItemTypeNum – Correlates to type of report coming out of our application
  • ItemNum – A individual timestamped report

Example:

  • ItemTypeGroupNum = 161 – The application’s block of reports within OnBase
  • ItemTypeNum = 5681 – Report group title = G/L File Maintenance
  • ItemNum = 250727772 – G/L File Maintenance – 6/25/2024

My 1st attempt and the resulting replies to review a similar, albeit different post here.

Next came attempts to use partition by and over. My SQL skills aren’t that sharp so this is possibly due to user error.

Next came an attempt to use outer apply and that did not succeed, I referenced this post.

My most recent attempt:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>SELECT
dt.itemtypenum
, dt.itemtypename
, tlx.MaxLogDate
FROM
hsi.itemdata as id
inner JOIN hsi.doctype as dt on dt.itemtypenum = id.itemtypenum /* do I need this join? */
outer apply
(
select tl.num, max(tl.logdate) as MaxLogDate
from hsi.transactionxlog as tl
where tl.num = id.itemnum
--and tl.itemnum = 1234
and tl.action in (32,35) /* showing only 'view' actions */
--and tl.logdate >= '2023-06-25'
group by tl.logdate, tl.num
) tlx
</code>
<code>SELECT dt.itemtypenum , dt.itemtypename , tlx.MaxLogDate FROM hsi.itemdata as id inner JOIN hsi.doctype as dt on dt.itemtypenum = id.itemtypenum /* do I need this join? */ outer apply ( select tl.num, max(tl.logdate) as MaxLogDate from hsi.transactionxlog as tl where tl.num = id.itemnum --and tl.itemnum = 1234 and tl.action in (32,35) /* showing only 'view' actions */ --and tl.logdate >= '2023-06-25' group by tl.logdate, tl.num ) tlx </code>
SELECT
          dt.itemtypenum
       , dt.itemtypename
       , tlx.MaxLogDate
FROM 
       hsi.itemdata as id
       inner JOIN hsi.doctype as dt on dt.itemtypenum = id.itemtypenum   /* do I need this join?  */
       outer apply
       (
              select tl.num, max(tl.logdate) as MaxLogDate
              from hsi.transactionxlog as tl
              where tl.num = id.itemnum
              --and tl.itemnum = 1234
              and tl.action in (32,35)       /* showing only 'view' actions  */
              --and tl.logdate >= '2023-06-25'   
              group by tl.logdate, tl.num
       ) tlx

The results I am getting are including multiple rows for the same ItemTypeNum but different ItemNum, with the most-recent accessed date for that individual ItemNum:

ItemTypeNum ItemName MaxLogDate
5257 Report Title 1 – 01/01/2024 01/02/2024
5257 Report Title 1 – 05/16/2024 06/11/2024
5681 G/L File Maintenance – 04/20/2024 05/15/2024
5681 G/L File Maintenance – 03/08/2024 06/01/2024
5370 Exception Report – 02/20/2024 NULL

What I am wanting to have returned would be only the 2nd, 4th, and 5th rows from the above table, the rows that have the max date for that group of ItemTypeNum:
|ItemTypeNum|ItemName|MaxLogDate|
|–|—|—|
|5257|Report Title 1 – 05/16/2024|06/11/2024|
|5681|G/L File Maintenance – 03/08/2024|06/01/2024|
|5370|Exception Report – 02/20/2024|NULL|

OnBase database diagram

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật