I'm facing a challenge in dynamically generating SQL queries based on incremental q_ids for a project I'm working on. Here's the scenario:
- I have a table
log_reportsthat contains logs of service activities, including timestamps and associated q_ids. - Each service log entry is associated with a cls and a q.
- My goal is to generate SQL queries that calculate statistics such as average, minimum, and maximum time differences between the log creation time and the current timestamp, for each combination of cls_id and q_id.
Current Approach:
Here's the SQL query I'm currently using: