Introducing PopSQL + dbt. The first SQL editor with built-in dbt support.Read more →
How to Create a View in SQL Server in SQL Server
Views allow to encapsulate or “hide” complexities, or allow limited read access to part of the data.
To create a view, use the
CREATE VIEW command:
-- syntax create view view_name as select_statement;
-- a view to show only products within category 1 create view category_1_products_v as select * from products where category = 1; -- a view to limit read access to only certain columns create view category_products_basic_v as select name, category, price from products; -- a view that displays top 10 products that provide highest sold value create view top_10_products_v as select top 10 p.name, p.category, p.price, ps.quantity_sold, p.price * ps.quantity_sold as sold_value from products p left join products_sold ps on p.id=ps.product_id order by sold_value desc;
Spread the wordTweet