Skip to content

Tag: sql-server

Retrieve rows where Column1 != Multiple Values from Column2

I have 2 Location columns. I need to find a way to show only exceptions, where Location1 != Location2, BUT there are multiple values in Location2 column that can be associated with value in Lcoation1. For example: San Diego in Location1 column can have 4 possible values in Location2 column (North, Central, So…

Count rows between time periods excluding time-overlap

I have a table where it holds some vehicle events, I need to count the number of event occurrences every 5 minutes. Sample : I was able to get the results by the following query : query results : The issue with the above results is that the query excluded Ids (15 and 28) the correct output should be :