views in sql
snippet in sql

what is a view in sql

user4435

In SQL, a view is a virtual table based on the result-set of an SQL statement.
A view contains rows and columns, just like a real table.
You can add SQL functions, WHERE, and JOIN statements to a view 
and present the data as if the data were coming from one single table.

-- syntax
CREATE VIEW view_name AS
SELECT column1, column2, ...
FROM table_name
WHERE condition;

create view

user4687

CREATE VIEW view_name AS SELECT id,category,MAX(created_at),content,title FROM table WHERE condition GROUP BY category

views in sql

user191

Views are created in order to store your queries as virtual
table. If there are a lot of columns and we don’t want to
use all columns and make the table simpler, we can create a
view and reuse it repeatedly. Actually, view does not store
any data however, it contains the retrieve statements to
provide reusability. We can create view if we use some
queries mostly.
create view EmployeeInfo as
select first_name || last_name as "Full Name"
from employees;

creating view in sql

user8730

The following SQL creates a view that shows all customers from Brazil:

CREATE VIEW [Brazil Customers] AS
SELECT CustomerName, ContactName
FROM Customers
WHERE Country = 'Brazil'; 

views in sql

user1087


CREATE VIEW view_name AS

SELECT column1, column2, ...

FROM table_name

WHERE condition;