2018-02-07

Feb 7 In-Class Exercise Thread.

Post Your Solutions to the Feb 7 In-class exercise to this thread.
Best,
Chris
Post Your Solutions to the Feb 7 In-class exercise to this thread. Best, Chris

-- Feb 7 In-Class Exercise Thread
SELECT * FROM
  a AS t1 FULL OUTER JOIN a AS t2
  WHERE t1.col <> t2.col
  ORDER BY t1.b;
(Edited: 2018-02-07)
<pre> SELECT * FROM a AS t1 FULL OUTER JOIN a AS t2 WHERE t1.col <> t2.col ORDER BY t1.b; </pre>

-- Feb 7 In-Class Exercise Thread
SELECT COUNT(*) FROM Peoples WHERE Peoples.birth_month = 'december' AND Peoples.age > 18 AND Peoples.age < 59 ORDER BY Peoples.ssn;
(Edited: 2018-02-07)
SELECT COUNT(*) FROM Peoples WHERE Peoples.birth_month = 'december' AND Peoples.age > 18 AND Peoples.age < 59 ORDER BY Peoples.ssn;

-- Feb 7 In-Class Exercise Thread
SELECT item, AVG(price) avg FROM ITEMTABLE GROUP BY item ORDER BY item;
(Edited: 2018-02-07)
SELECT item, AVG(price) avg FROM ITEMTABLE GROUP BY item ORDER BY item;

-- Feb 7 In-Class Exercise Thread
SELECT *
FROM EMPLOYEE
WHERE employee_id > 9000
ORDER BY employee_id;
(Edited: 2018-02-07)
SELECT * FROM EMPLOYEE WHERE employee_id > 9000 ORDER BY employee_id;

-- Feb 7 In-Class Exercise Thread
SELECT *
FROM bankAccount
WHERE balance >= AVG(balance) 
(Edited: 2018-02-07)
<pre> SELECT * FROM bankAccount WHERE balance >= AVG(balance) </pre>

-- Feb 7 In-Class Exercise Thread
CREATE TABLE slow (
     num int
);
SELECT num FROM slow ORDER BY num ASC;
CREATE TABLE slow ( num int ); SELECT num FROM slow ORDER BY num ASC;

-- Feb 7 In-Class Exercise Thread
SELECT * FROM Employees ORDER BY Age ASC
SELECT * FROM Employees ORDER BY Age ASC

-- Feb 7 In-Class Exercise Thread
student: Daniel Vu
Select *
from ( select attritubeA,attribute B from Table)
where attributeA like '%abc' AND orderby desc
(Edited: 2018-02-07)
student: Daniel Vu Select * from ( select attritubeA,attribute B from Table) where attributeA like '%abc' AND orderby desc

-- Feb 7 In-Class Exercise Thread
SELECT * 
FROM table
WHERE attr IN (SELECT * FROM table)
ORDER BY attr ASC
(Edited: 2018-02-07)
<pre> SELECT * FROM table WHERE attr IN (SELECT * FROM table) ORDER BY attr ASC </pre>
[ Next ]
X