× 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.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.