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



Aggregate functions do not allow nesting. I've simulated nested functions by
using sub-queries, but performance was lousy.

Eric DeLong
Sally Beauty Company
MIS-Sr. Programmer/Analyst
940-898-7863 or ext. 1863



-----Original Message-----
From: Matthias Oertli [mailto:oertlim@s054.aone.net.au]
Sent: Sunday, September 23, 2001 11:54 PM
To: midrange-l@midrange.com
Subject: Re: Elementary SQL question


Many thanks for all the replies.

The result I was looking for is one single number (therefore no group
by/order by clauses) which basically is the number of transaction
records divided by the number of customer records giving the average
number of transactions per customers.

The statement sent by Eric DeLong (which put into practice the theory of
Joe Pluta) seems to fit my requirements exactly. I would've never
thought of that trick! Thanks!

Btw, the qmquery manager does not allow nested functions, eg.
avg(count(field)). Is this a limitation that does not exist with the
full blown SQL LPP?

Best regards,
Matthias

>
> How about this (run against order hdr/dtl files):
>
> SELECT (COUNT(DISTINCT char(B.ODORD#)||char(B.ODOELN)) /
>         COUNT(DISTINCT A.OHORD#))
> FROM oepordh a left outer join oepordd b on A.OHORD#=B.ODORD#
>
> The trick is to make sure the numerator (in my case, the order
number||Order
> line#) is a unique value. The distinct keyword removes duplicate entries,
so
> make sure you account for that.
>

--
--------------------------------------------------
Matthias Oertli   matthias.oertli@mdi.com.au
_______________________________________________
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@midrange.com
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/cgi-bin/listinfo/midrange-l
or email: MIDRANGE-L-request@midrange.com
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.




As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.