select trk.recordOwnerId ownerId, trk.recordOwnerType ownerType, b.broker_name companyName, trk.recordTableCd subjectType, trk.eventCd, COUNT(*) instanceCount, min( eventTime ) minEventTime, max( eventTime ) maxEventTime from tbl_TRK_libraryActivity trk inner join tblBrokers b on b.broker_Id = trk.recordOwnerId where SCRIPTnAME IS NOT NULL and eventTime >= DATEADD( day, -30, getDate() ) and trk.recordOwnerType = 'BRO' group by trk.recordOwnerId, trk.recordOwnerType, b.broker_name, trk.recordTableCd, trk.eventCd union select ws.portal_ownerId ownerId, ws.portal_ownerType ownerType, b.broker_name companyName, 'SYS' subjectType, trk.eventCd, COUNT(*) instanceCount, min( trk.eventTime ) minEventTime, max( trk.eventTime ) maxEventTime from tbl_TRK_MemberActivity trk inner join FSEnablers..tbl_CUS_Websites ws on ws.WebsiteID = convert( int, REPLACE( Site, 'salesteamportal_', '' )) inner join tblBrokers b on b.broker_Id = ws.portal_ownerId where trk.EventCD = 'LI' and site like 'salesteamportal%' and trk.eventTime >= DATEADD( day, -30, getDate() ) and ws.portal_ownerType = 'BRO' group by ws.portal_ownerId, ws.portal_ownerType, b.broker_name, trk.eventCd union select trk.recordOwnerId ownerId, trk.recordOwnerType ownerType, m.mfr_name companyName, trk.recordTableCd subjectType, trk.eventCd, COUNT(*) instanceCount, min( eventTime ) minEventTime, max( eventTime ) maxEventTime from tbl_TRK_LibraryActivity trk inner join tblManufacturers m on m.mfr_Id = trk.recordOwnerId where SCRIPTnAME IS NOT NULL and eventTime >= DATEADD( day, -30, getDate() ) and trk.recordOwnerType = 'MFR' group by trk.recordOwnerId, trk.recordOwnerType, m.mfr_name, trk.recordTableCd, trk.eventCd union select ws.portal_ownerId ownerId, ws.portal_ownerType ownerType, m.mfr_name companyName, 'SYS' subjectType, trk.eventCd, COUNT(*) instanceCount, min( trk.eventTime ) minEventTime, max( trk.eventTime ) maxEventTime from tbl_TRK_MemberActivity trk inner join FSEnablers..tbl_CUS_Websites ws on ws.WebsiteID = convert( int, REPLACE( Site, 'salesteamportal_', '' )) inner join tblManufacturers m on m.mfr_Id = ws.portal_ownerId where trk.EventCD = 'LI' and site like 'salesteamportal%' and trk.eventTime >= DATEADD( day, -30, getDate() ) and ws.portal_ownerType = 'MFR' group by ws.portal_ownerId, ws.portal_ownerType, m.mfr_name, trk.eventCd select * from qmd_activity order by companyName, subjectType, eventCd, instanceCount desc select min ( minEventTime ) startTime, max( maxEventTime ) endTime from qmd_activity select subjectType, eventCd, sum( instanceCount ) instanceCount from qmd_results group by subjectType, eventCd order by subjectType, eventCd select companyName, ownerId, ownerType, sum( instanceCount ) instanceCount from qmd_results group by companyName, ownerId, ownerType order by instanceCount desc

STP Activity in Past 30 Days

#lsDateFormat( qmd_timeframe.startTime )# through #lsDateFormat( qmd_timeframe.endTime )#

select instanceCount from qmd_results where ownerId = and ownerType= and subjectType = and eventCd =
CompanyTotal #subjectType#
#eventCd#
#htmleditformat( companyName )# #instanceCount# #val( qmd_getInstances.instanceCount )#