0% found this document useful (0 votes)
27 views2 pages

Use Select As As As From As As As On On: 'Pidion in Sekel' ' Pidion As $' 'Quarter'

The document contains SQL queries on the Northwind database: 1. The first query selects the product quantity, price in shekels and dollars, customer ID, order date and quarter for orders where the quantity times price is not between 50 and 300. 2. The second query selects the customer ID and company name for customers with no orders. It returns 2 customers. 3. The third query selects distinct company names from customers in Brazil or the UK, with orders in quarters 2 or 4, where the product units in stock is between 5 and 35 and the supplier country includes D, C or A. It joins this to itself to return company name pairs where the second name is alphabetically after the first

Uploaded by

elad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Use Select As As As From As As As On On: 'Pidion in Sekel' ' Pidion As $' 'Quarter'

The document contains SQL queries on the Northwind database: 1. The first query selects the product quantity, price in shekels and dollars, customer ID, order date and quarter for orders where the quantity times price is not between 50 and 300. 2. The second query selects the customer ID and company name for customers with no orders. It returns 2 customers. 3. The third query selects distinct company names from customers in Brazil or the UK, with orders in quarters 2 or 4, where the product units in stock is between 5 and 35 and the supplier country includes D, C or A. It joins this to itself to return company name pairs where the second name is alphabetically after the first

Uploaded by

elad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

5

use Northwind

select (od.Quantity*od.UnitPrice) as 'pidion in sekel' ,


(od.Quantity*od.UnitPrice)*3.52 as ' pidion as $' ,
c.CustomerID , o.OrderDate , DATEPART(QUARTER,o.OrderDate) as 'Quarter'

from Customers as c inner join Orders as o inner join [Order Details] as od

on od.OrderID=o.OrderID
on o.CustomerID=c.CustomerID

where (od.Quantity*od.UnitPrice) not between 50 and 300

1348

7
use Northwind

select distinct c.CustomerID , c.CompanyName

from Customers as c left join Orders as o


on o.CustomerID=c.CustomerID

where o.OrderDate is NULL

use Northwind

select distinct q1.CompanyName, q2.CompanyName


from
(select c.CompanyName, c.Country
from Customers as c
inner join orders as o
inner join [Order Details] as od
inner join Products as p
inner join Suppliers as s
on s.SupplierID=p.SupplierID
on p.ProductID=od.ProductID
on od.OrderID=o.OrderID
on o.CustomerID=c.CustomerID
where c.Country in ('Brazil' , 'UK' ) and datepart(quarter,o.OrderDate) in
(2,4)
and (p.UnitsInStock between 5 and 35) and s.Country like '%[DCA]') as q1

inner join
(select c.CompanyName, c.Country
from Customers as c
inner join orders as o
inner join [Order Details] as od
inner join Products as p
inner join Suppliers as s
on s.SupplierID=p.SupplierID
on p.ProductID=od.ProductID
on od.OrderID=o.OrderID
on o.CustomerID=c.CustomerID
where c.Country in ('Brazil' , 'UK' ) and datepart(quarter,o.OrderDate) in
(2,4)
and (p.UnitsInStock between 5 and 35) and s.Country like '%[DCA]') as q2

on q2.CompanyName>q1.CompanyName

You might also like