Maybe I worked to long but I have no clue how to solve this !
How can I count the number of rows returned by this query ?
(I need to use this value in a stored procedure)
SELECT
AUTO_ID_CUSTOMER
, SUM(UNIT_QTY*UNIT_PRICE)
FROM V_TRANSACTIONS
WHERE INV_DATE > '01/01/2006'
GROUP BY AUTO_ID_CUSTOMER
HAVING SUM(UNIT_QTY*UNIT_PRICE) < 100000
I also tried something like
select count(distinct v1.auto_id_customer)
FROM V_TRANSACTIONS v1
WHERE v1.INV_DATE > '01/01/2006'
and (select sum(v2.UNIT_QTY*v2.UNIT_PRICE)
FROM V_TRANSACTIONS v2
where v2.auto_id_customer = v1.auto_id_customer
and v2.INV_DATE > '01/01/2006') < 100000
which works, but unfortunately the execution time on even a small table is not acceptable (> 1 min.)