Question Parameshwaran Muthaiyan · Apr 11, 2024

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_reports that 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:

0
0 303
Question Parameshwaran Muthaiyan · Apr 4, 2024

For example, I have two timestamp values ('2024-04-01 10:00:00', '2024-04-01 11:30:30'). I would like to find the difference between these two timestamps, and I need the result in hours:minutes:seconds (hh:mm:ss) format.

Expected Output: 01:30:30


Note: I need an SQL query command. I should not use ClassMethod, Function, or Stored Procedure.


Could anyone please provide me with an SQL query for my question?

0
0 287