Skip to content

Tag: time

SQL: Split time interval into intersects of one hour

I am new to SQL, where I am trying to split time intervals into multiple rows of one hour, together with an indicator of how many minutes the interval overlaps each hour. My data: What I would like: What would be the easiest/fastest way to do this? Answer Try something like this: demo Result for sample data

SQL Query Comparing Date

I have a table of items with a ‘date_added’ column. What I want to do is select all the items added during the last two weeks. How can I do that? Answer If you are using MS SQL Server try this code: For MySQL try:

MySQL: Count the distinct rows per day

I have an interesting query I need to do. I have a table with an INT column containing ip address numbers (using INET_ATON), and a timestamp column. I want to be able to count the number of unique ip address columns there are per day. That is, how many distinct ip rows there are in each day. So, for example,