Skip to content
Advertisement

Tag: tsql

Referring to a Column Alias in a WHERE Clause

I get “invalid column name daysdiff”. Maxlogtm is a datetime field. It’s the little stuff that drives me crazy. Answer Normally you can’t refer to field aliases in the WHERE clause. (Think of it as the entire SELECT including aliases, is applied after the WHERE clause.) But, as mentioned in other answers, you can force SQL to treat SELECT to

SQL speed up performance of insert?

I am performing some test on sql server and I want to get the best insert speed possible. The statement I use is something like this: INSERT INTO db_Test_databse..tbl_test with(rowlock) ( …

Group by every N records in T-SQL

I have some performance test results on the database, and what I want to do is to group every 1000 records (previously sorted in ascending order by date) and then aggregate results with AVG. I’m actually looking for a standard SQL solution, however any T-SQL specific results are also appreciated. The query looks like this: Answer Something like that should

Advertisement