Skip to content

Tag: sql-server

SQL Counting Rows based on break values

Frequently I need to do something in SQL Server that I just don’t know how to do properly. Basically, if I have a table #sample that is like this: DEPARTMENT DATE ACCOUNTING A FINANCE A PAYROLL A ACCOUNTING B PAYROLL A FINANCE A PAYROLL B PAYROLL C I need to query that table to get an output that is thi…

SQL Find/Count similar duplicates

I am trying to to do a count on all records that are similar. Eg. I have 2 records 1 is 1A Smith St and the other is 1 Smith St. So this data needs to be returned/counted as 1. Any assistance would be gratefully appreciated. Thanks Answer Counting those where the (street, number) combination isn’t uniqu…

Find duplicate data in last 1 hour

I am looking for a SQL script to find the data which has more than 2 entries in last 1 hour. I have a table having user_id & event_time. I want a way to find out if the user_id has more than 1 entries in last 1 hour. I have tried below till now: Create temp table to put all