Skip to content

Oracle SQL – count number of active/open tickets per hour by day

I have a dataset from oracle db that looks something like this: I need to calculate the number of active tickets in an hour time slot. So if the ticket was opened before that hour, and closed after the hour it would be counted. All days and hours need to be represented regardless if there are active tickets o…

How to select other rows in GROUP BY

Sorry for the bad title. I don’t know how to summarize it better. I have a table with unix timestamps and other values, like the following. time value 1620916380 110 1620916440 100 1620916500 120 1620916560 120 1620916660 90 The entries are always one minute apart. I want to group entries into 5-minute …

Two intervals coincide at some point in SQL-Server

How to know if two intervals coincide at some point? I have two tables that store two intervals where the values ​​mean meters. The first interval corresponds to geological codes (VBv, P4, etc). The second interval corresponds to samples. They are connected through a field called Hole ID. I need all the sampl…

Round timestamp to 30 minutes interval to group by

Problem I want to group my data by currency, timestamp and show all type value like table of comparison with interval of 30 minutes, for now my created time is 1 minute or less different so if i group with created time it will still showing 4 rows cause of different timestamp, is there a way to round the time…

Generate random date into series [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 11 …

rank with the sum

Below is the table: where I want to rank the category based on weightage desc, expected results: what was already tried: select desnse_rank() over (partition by category order by weightage desc), but I need to rank it based on sum(weightage) per category. Answer With a CTE you can do the calculations one by o…

Unable to use Cursor in separate function

I’m currently tryign to learn how to use SQLite3 and am trying to seperate setting up the DB through functions. My second function is where I’m having the error : AttributeError: ‘NoneType’ object has no attribute ‘cursor’. After looking at the SQLite3 doucmentation, I got …