Relative Content

Tag Archive for sql-serversql-server-2022

SQL Server is very slow with SELECT from small table

I have a database that was given to me by a coworker in the form of a .bak file. I restored it to a new db, and I have 1 table with about 63,000 rows. When I try a query like “SELECT TOP (1000) …” it spins forever – I let it go 5 minutes before I stopped it, and it had only returned a couple screenfuls of rows (less than 100).

Compounding values from previous months

My manager wants me count each center that has an order. If a center make one order within the beginning of the last two months, it is considered active for the next two months from the month that it made an order. Example: if center ‘AR238’ made an order February 1rst, then it is considered active for the next two months. So it is active until the end of April if it does not make another order in march or April. I am trying to count each active center for each month, compounding from the previous months. So if a center made an order in February, I need to be able to count that for Feb, Mar, and April. Please assist on how to do that. Also I need the query to be included into the query I already have written out. This Query will just add an extra column to the table I already have from my original query. I will post my original query below.