Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE DATABASE lab6_1;
- USE lab6_1;
- CREATE TABLE orderTable
- (
- o_id VARCHAR(10),
- orderdate VARCHAR(100),
- orderprice INT,
- customer VARCHAR(20)
- );
- INSERT INTO orderTable(o_id,orderdate,orderprice,customer)
- VALUES (1,'2008/11/12',1000,'hansen');
- INSERT INTO orderTable(o_id,orderdate,orderprice,customer)
- VALUES (2,'2008/10/12',1600,'nilsen');
- INSERT INTO orderTable(o_id,orderdate,orderprice,customer)
- VALUES (3,'2008/09/12',700,'hansen');
- INSERT INTO orderTable(o_id,orderdate,orderprice,customer)
- VALUES (4,'2008/08/12',300,'hansen');
- INSERT INTO orderTable(o_id,orderdate,orderprice,customer)
- VALUES (5,'2008/07/12',2000,'jensen');
- INSERT INTO orderTable(o_id,orderdate,orderprice,customer)
- VALUES (6,'2008/11/12',100,'hansen');
- SELECT AVG(orderprice) AS orderAverage FROM orderTable;
- SELECT customer FROM orderTable
- WHERE orderprice>(SELECT AVG(orderprice) AS orderAverage FROM orderTable);
- SELECT COUNT(customer) FROM orderTable WHERE customer='nilsen';
- SELECT COUNT(*) FROM orderTable;
- /*select first(orderprice) from orderTable;*/
- /*select orderprice from orderTable order by o_id limit 1;*/
- SELECT top 1 orderprice FROM orderTable ORDER BY o_id;
- /*select last(orderprice) from orderTable;*/
- SELECT SUM(orderprice) FROM orderTable;
- SELECT customer,SUM(orderprice) FROM orderTable GROUP BY customer;
- SELECT customer,SUM(orderprice) FROM orderTable GROUP BY customer HAVING SUM(orderprice)<2000;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement