-- $Id: q15-tpch11.sql 2657 2007-06-12 16:08:15Z rdempsey $
-- 15th query in 100 GB stream0 (tpch11).

-- 15th query in the 100 GB stream.
-- tpch11
SELECT 
	PS_PARTKEY,
	SUM(PS_SUPPLYCOST * PS_AVAILQTY) AS VALUE
FROM 
	PARTSUPP,
	SUPPLIER,
	NATION
WHERE 
	PS_SUPPKEY = S_SUPPKEY AND
	S_NATIONKEY = N_NATIONKEY AND
	N_NAME = 'RUSSIA'
GROUP BY 
	PS_PARTKEY HAVING 
		SUM(PS_SUPPLYCOST*PS_AVAILQTY) > ( 
			SELECT
				SUM(PS_SUPPLYCOST * PS_AVAILQTY) * 0.0000010000
			FROM 
				PARTSUPP,
				SUPPLIER,
				NATION
			WHERE 
				PS_SUPPKEY = S_SUPPKEY AND
			S_NATIONKEY =	N_NATIONKEY AND
			N_NAME = 'RUSSIA'
		)
ORDER BY 
	VALUE DESC;

