×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
It'd be nice if someone had some examples which could show typical cases of where SQL would be >appropriate, and where it would not.
Appropriate uses of SQL... anything "set" based:
Select the Item-Balance across all warehouses for item 12345:
select sum(ItemBalance) from Item-Warehouse-File where ItemNumber = 12345
Select the OrderValue for a given order:
select sum(LineValue) from OrderDetail where OrderID = 12345
Select the average order value for salesrep 12345, where the salesrep is stored on the customer:
select avg(OrderValue) from OrderHeader OH
join Customer C
on OH.CustomerID = C.CustomerID
and C.SalesRep = 12345
Select the total order value, by customer, for salesrep 12345, largest customer first, provided the customer has placed at least 5 orders:
select CustomerID, sum(OrderValue) as TotalValue, count(*) from OrderHeader OH
join Customer C
on OH.CustomerID = C.CustomerID
and C.SalesRep = 12345
group by CustomerID
having count(*) >= 5
order by TotalValue desc
Select the average order value for orders that are ordered by "OEM" customers, where the order contains any item that is in the item class of "Drill":
select avg(OrderValue) from OrderHeader OH
join OrderDetail OD
on OD.OrderID = OH.OrderID
join Customer C
on OH.CustomerID = C.CustomerID
and C.CustomerType = "OEM"
join Item I
on OD.ItemNumber = I.ItemNumber
and I.ItemClass = "Drill"
-Walden
As an Amazon Associate we earn from qualifying purchases.