By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,501 Members | 1,859 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,501 IT Pros & Developers. It's quick & easy.

Query from the Aggregated Query with different projection

P: n/a
Hello All,

Below is how my data looks like
Branch Item Customer Sales
10 1 C1 300
10 1 C2 400
10 1 C3 200
10 2 C1 500
10 2 C3 300
10 3 C1 1200
With this Query

SELECT
BRANCH,
ITEM,
COUNT(DISTINCT Customer || '-' || Branch)
FROM
TABLE1
GROUP BY
BRANCH,
ITEM
HAVING
SUM(SALES) BETWEEN 1 AND 1000

The output will be

Branch Item CustomerCount
10 1 3
10 2 2

and

Item 3 will not come since the value is 1200.

Now I need the Distinct Customers who were part of that Query where
the distinct Customer Count is only 3 and not the Sum (5). Now how do
we get that value with the given query with all conditions applied.

Remember the SUM(SALES) should be applied to Branch And Item and from
that I need the distinct CustomerCount.
Any help is highly appreciated.
Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.