PART 1 Retrieving Data using SQL

  1. SQL CODE:

select fname as `First Name`, surname as `Surname`,email as `Email address`, gender as
`Gender`,
strftime(‘%d-%m-%Y’,registration_date) as `Date joined`, strftime(‘%Y’,’now’)- strftime(‘%Y’,dob) as `Current Age`
from customers
where registration_date >= ‘2020-01-01’ and gender = ‘female’
ORDER by gender,
`Current Age` ;

b) SQL CODE:

SELECT c.fname as `First Name`,c.surname as `Surname`,o.orderid as `Order No`, p.product_name as `Product Description` ,p.seller as `Seller Name`,
o.orderedquantity as `Quantity Ordered` ,(‘£ ‘||printf(“%.2f”, o.orderedquantity
*p.product_price )) as `Price`,
o.orderstatus as `Ordered Product Status`,strftime(‘%d-%m-%Y’,o.orderdate) as `Ordered Date` from orders o
join customers c on o.userid = c.id join products p on o.productid= p.productid where o.userid = 10019
ORDER by `Ordered Date` DESC
;

SELECT c.fname as `First Name`,c.surname as `Surname`,o.orderid as `Order No`, p.product_name as `Product Description`,p.seller as `Seller Name`,
o.orderedquantity as `Quantity Ordered`,(‘£ ‘||printf(“%.2f”, o.orderedquantity
*p.product_price)) as `Price`,
o.orderstatus as `Ordered Product Status`,strftime(‘%d-%m-%Y’,o.orderdate) as `Ordered Date` from orders o
join customers c on o.userid = c.id join products p on o.productid= p.productid where o.userid = 10019
ORDER by `Ordered Date` DESC
;

To get access to the complete article, please send an email at sales@thedocumentco.com