Skip to content
Advertisement

Tag: sql-server

MS Sql: Conditional ORDER BY ASC/DESC Question

I want to to make to make the ordering in my query conditional so if it satisfiess the condition it should be ordered by descending For instance: Answer Don’t change the ASC or DESC, change the sign of the thing being sorted-by: The OP asks: Guys, I am not the SQL Expert, please explain me what means the id and

Difference between CTE and SubQuery?

From this post How to use ROW_NUMBER in the following procedure? There are two versions of answers where one uses a sub-query and the other uses a CTE to solve the same problem. Now then, what is the advantage of using a CTE (Common Table Expression) over a ‘sub-query`(thus, more readable what the query is actually doing) The only advantage

How can I find duplicate entries and delete the oldest ones in SQL?

I’ve got a table that has rows that are unique except for one value in one column (let’s call it ‘Name’). Another column is ‘Date’ which is the date it was added to the database. What I want to do is find the duplicate values in ‘Name’, and then delete the ones with the oldest dates in ‘Date’, leaving the

What are Covering Indexes and Covered Queries in SQL Server?

Can you explain the concepts of, and relationship between, Covering Indexes and Covered Queries in Microsoft’s SQL Server? Answer A covering index is one which can satisfy all requested columns in a query without performing a further lookup into the clustered index. There is no such thing as a covering query. Have a look at this Simple-Talk article: Using Covering

Advertisement