This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```sql | |
MERGE INTO accounts t USING monthly_accounts_update s | |
ON (t.customer = s.customer) | |
WHEN MATCHED AND s.address = 'Centreville' | |
THEN DELETE | |
WHEN MATCHED | |
THEN UPDATE | |
SET purchases = s.purchases + t.purchases, address = s.address | |
WHEN NOT MATCHED | |
THEN INSERT (customer, purchases, address) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```sql | |
-- hp vertica sample sql | |
CREATE VIEW myview AS | |
SELECT SUM(annual_income), customer_state | |
FROM public.customer_dimension | |
WHERE customer_key IN | |
(SELECT customer_key | |
FROM store.store_sales_fact) | |
GROUP BY customer_state |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```sql | |
-- netezza sample sql | |
INSERT INTO films SELECT * FROM tmp; | |
INSERT INTO emp_copy WITH employee AS (select * from | |
emp) SELECT * FROM employee; | |
UPDATE emp_copy SET grp = 'gone' WHERE id = | |
(WITH employee AS (select * from emp) SELECT id FROM employee WHERE id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```sql | |
-- sybase sample sql | |
create view accounts (title, advance, amt_due) | |
as select title, advance, price * total_sales | |
from titles | |
where price > $5 | |
create view cities | |
(authorname, acity, publishername, pcity) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```sql | |
-- sql server sample sql | |
CREATE TABLE dbo.EmployeeSales | |
( DataSource varchar(20) NOT NULL, | |
BusinessEntityID varchar(11) NOT NULL, | |
LastName varchar(40) NOT NULL, | |
SalesDollars money NOT NULL | |
); | |
GO | |
CREATE PROCEDURE dbo.uspGetEmployeeSales |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```sql | |
-- sparksql sample sql | |
CREATE TABLE person (id INT, name STRING, age INT, class INT, address STRING); | |
SELECT * FROM person | |
PIVOT ( | |
SUM(age) AS a, AVG(class) AS c | |
FOR name IN ('John' AS john, 'Mike' AS mike) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```sql | |
-- redshift sample sql | |
Create table sales( | |
dateid int, | |
venuestate char(80), | |
venuecity char(40), | |
venuename char(100), | |
catname char(50), | |
Qtr int, | |
qtysold int, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```sql | |
CREATE TABLE orders_column_aliased (order_date, total_price) | |
AS | |
SELECT orderdate, totalprice | |
FROM orders; | |
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```sql | |
-- postgresql sample sql | |
create view v2 as | |
SELECT distributors.name | |
FROM distributors | |
WHERE distributors.name LIKE 'W%' | |
UNION | |
SELECT actors.name | |
FROM actors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```sql | |
-- openedge sample sql | |
CREATE VIEW ne_customers AS | |
SELECT name, address, city, state | |
FROM customer | |
WHERE state IN ( 'NH', 'MA', 'ME', 'RI', 'CT', 'VT' ) | |
WITH CHECK OPTION ; | |
INSERT INTO neworders (order_no, product, qty) |
NewerOlder