0 Replies - 1629 Views - Last Post: 30 January 2008 - 12:27 PM

#1 Nykc   User is offline

  • Gentleman of Leisure
  • member icon

Reputation: 740
  • View blog
  • Posts: 8,654
  • Joined: 14-September 07

Create A View Using TOP Keyword MS SQL Server

Posted 30 January 2008 - 12:27 PM

Description: Determine logic required to write query. Specify name of view with CREATE VIEW. Write query to retrieve records. Specify AS keyword before query statement. Execute statements to create view. Query view to verify it has been created. The TOP keyword is specified in a SELECT clause to limit the number of records displayed
CREATE VIEW viewname [(columnname1, columnname2, columnname3)]
AS SELECT TOP value [PERCENT] SUM (columnname3) AS 'Colname', columnname2, columnname3
FROM tablename1 [, tablename2]
WHERE columnname4=columnname5
GROUP BY columnname1, columnname2
ORDER BY SUM(columnname3) DESC

Is This A Good Question/Topic? 0
  • +

Page 1 of 1