1)

create table product (
       productid bigint
);

select description
from product
where productid = 42

2)

create table customer (
         custid bigint;
         fname varchar(20),
         lname varchar(20),
         street1 varchar(50),
         street2 varchar(50),
         city varchar(8),
         state varchar(2),
         zip varchar(5),
);

select fname, lname, street1, street2, city, state, zip
from customer
where customerid =42;

3)
select product
from purchase
where customerid = 42

4)
select a.*
from customer a natural left outer join purchase b
where b.customerid = null

5)
select a.*
from product
where a.productid = NULL

6)
select purchase
from customer
where zip = 10001

7)
withcustpurchase as (
         select productid {
                100.0 * (
                      SUM ( IF( productid = 42, 1, 0) ) / count (purchase_id)
                 ) , 1 ) AS percent_total
         from purchase
)

8)
withcustpurchase as (
         select productid {
                100.0 * (
                      SUM ( IF( productid = 42, 24, 1, 0) ) / count (purchase_id)
                 ) , 1 ) AS percent_total
         from purchase
)



9)

select product
from purchase
where state = 'NY'

10)

select product
from purchase
where region = 'North East'

Comments

Popular posts from this blog

MR. AKPARA, O. TV AND FILM PRODUCTIONS, LLC