Tag: sql server

Community

Parent-Child Dimensions

A parent-child dimension is based on two dimension table columns that together define the lineage relationships among the members of the dimension. One column, called the member key column, identifies each member; the other column, called the parent key column, identifies the parent of each member.

Community

Top N rows for each X

(Rudy Limeback) I want a query for retrieving the top two recently inserted records for each id. My table has columns id, adate, and description. There are five records with id 2 and four records with id 3. I want to retrieve top two records for both id 2 and 3. I should get total four records,

Community

Table Variables In T-SQL

(Scott) Microsoft introduced table variables with SQL Server 2000 as an alternative to using temporary tables. In many cases a table variable can outperform a solution using a temporary table, although we will need to review the strengths and weaknesses of each in this article.