thank you, I'm so grateful for your help
by bestbird7788 - 5/17/12 7:51 PM
In Reply to: Re: analysis by Kees_B
I'm willing to pay for the right one, including SPSS if it is useful.
I had check solutions you recommended and I dont' know how to make a clear dicision.
It seemes there are too many solutions.I think It's hard to image how to give a suggestion and make a choice without a discussible example.
So, I will give a discussible example below (with my friends's help, It's some difficult) ,please give me a suggestion about which solution is more fit for it, and how to use that solution to solve this problem( more details are ideal).
for example, I needs to compute the product whose annual sales values are all among the top 100
MSSQL data structure( sales table's fields): productID, time, value
SQL solution is as below:
---------------------------------------------------------
WITH sales1 AS (
SELECT productID, YEAR(time) AS year, SUM(value) AS value1
FROM sales
GROUP BY productID, YEAR(time)
)
SELECT productID
FROM (
SELECT productID
FROM (
SELECT productID,RANK() OVER(PARTITION BY year ORDER BY value1 DESC) rankorder
FROM sales1 ) T1
WHERE rankorder<=100) T2
GROUP BY productID
HAVING COUNT(*)=(SELECT COUNT(DISTINCT year ) FROM sales1)
----------------------------------------------------------------------------------------
Was this reply helpful? (0) (0)
Staff pick