Announcement

Migration of this forum

Dear users of this forum,

we are pleased to inform you that we will be updating the software behind this forum in the near future.

Existing posts, users and categories will remain untouched.

Important:

  • Each user will need to reset their password.
  • Please select "I forgot my password".
  • Enter the email address you used to register in this forum.
  • You will receive an email with a link to set a new password.
  • Please choose a new (secure) password and confirm the process.

We will keep you informed in the pinned thread.

Kind regards,
Your ReportServer Team


Migration des Forums

Liebe Nutzer dieses Forums,

wir freuen uns, euch mitteilen zu können, dass wir in naher Zukunft die Software hinter diesem Forum aktualisieren werden.

Existierende Beiträge, Nutzer und Kategorien bleiben weiterhin bestehen!

Wichtig:

  • Jeder Nutzer muss sein Passwort neu vergeben.
  • Wählt dazu einfach "Ich habe mein Passwort vergessen".
  • Gebt die E-Mail-Adresse ein, mit der ihr registriert seid.
  • Ihr erhaltet eine E-Mail mit einem Link zur Passwortvergabe.
  • Bitte wählt ein neues (sicheres) Passwort und bestätigt den Vorgang.

Wir halten euch im angepinnten Beitrag auf dem Laufenden!

Mit vielen Grüßen
Euer ReportServer Team

#1 2024-08-12 05:07:31

zach.mathew
Member
Registered: 2015-04-17

Trying to generate report statistics. Is this SQL query correct ?

I'm looking to generate some statistics for the instance of ReportServer we're using. Using version 3.0.6

We're trying to get a list of most run reports within a date range.

select rex.value reportid, rex.reportname, count(1) 
  from (
		select r.name_field reportname, r.id r_id, e.action, e.date_field , e.user_id userid, p.key_field, p.value
		  FROM rs_audit_log_entry e
		 INNER JOIN rs_audit_log_property p
		    ON e.entity_id = p.log_entry_id 
		   and e.date_field >= $P{startdate}
           and e.date_field < to_date($P{enddate} , 'YYYY-MM-DD') + interval '1 day'
		  LEFT OUTER JOIN (
		       select distinct id, name_field 
		         from rs_report_a rra 
		        where name_field is not null order by id) r
		    ON cast(r.id AS varchar(255)) = p.value    
		 where e.action = 'END_REPORT_EXECUTION' 
		   and p.key_field = 'report_id'
		   --and p.value = '4868256'
   	    ) rex
  group by 1, 2
  order by 3 desc

Thanks

Zach

Offline

#2 2024-08-12 10:02:33

IF_Adrian
Member
Registered: 2021-10-29

Re: Trying to generate report statistics. Is this SQL query correct ?

select rex.value reportid, rex.reportname, count(1) 
  from (
		select r.name_field reportname, r.id r_id, e.action, e.date_field , e.user_id userid, p.key_field, p.value
		  FROM rs_audit_log_entry e
		 INNER JOIN rs_audit_log_property p
		    ON e.entity_id = p.log_entry_id 
		   and e.date_field >= '2020-04-01'::date
           and e.date_field < '2026-04-01'::date
		  LEFT OUTER JOIN (
		       select distinct id, name_field 
		         from rs_report_a rra 
		        where name_field is not null order by id) r
		    ON cast(r.id AS varchar(255)) = p.value    
		 where e.action = 'END_REPORT_EXECUTION' 
		   and p.key_field = 'report_id'
		   --and p.value = '4868256'
   	    ) rex
  group by 1, 2
  order by 3 desc

| Report ID | Report Name                | Count |
| --------- | -------------------------- | ----- |
| 74770     | Top Employees - Dashboard  | 30    |
| 74724     | T_AGG_CUSTOMER - Basis     | 27    |
| 61892     | variante                   | 20    |
| 74910     | CustomerCreditLine         | 15    |
| 75004     | Store Sales                | 15    |
| 200       | Audit Logs                 | 8     |

This sql does work on my postgresdb (schema 4.6.3). So your sql seems to be correct.

Do you want to use this to create a dynamic list report ?

If so here are a couple of thing to be aware of.

* the sql query is gonna be wrapped by reportserver meaning that orderby will likely not work and needs to be configured inside the report.
* using the date parameter can be confusing and is not intuitive - i suggest you to use a text parameter and cast it.

If you have more specific questions feel free to ask and include more information about your usecase.

Kind regards

Offline

Board footer

Powered by FluxBB