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…
select smalldatetime between two strings
What am I doing wrong ? Desired Output: Column InRange should contain YES for two last rows. Answer Try specifying ISO format dates, more than likely your regional settings are having an effect. If you use YYYYMMDD there is no ambiguity. The following works fine:
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…
Split data in one column and convert them into column headers in MS Access
I’m trying to convert a column of data into headers on a new table. This question has a good answer but the SQL doesn’t work in Access, I get a syntax error on the very first part of the SELECT statement. Here’s the code, with example names: Should this code work or is it not compatible with…
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 …
Accpt employee number from user fetch the employee details from the “Employee” table and store it to a PLSQL record type variable and print the same
Accpt employee number from user fetch the employee details from the “Employee” table and store it to a PLSQL record type variable and print the same. Answer Here’s one option (if that’s what you’re looking for):
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 …