[solved]problematic query urgent :)
Posted: Thu Nov 17, 2005 8:04 am
process -> PK process_id
orders -> PK orders_id
The problem is I can have more than one values with same product_id for a single 'orders_id'
I want to count only one of them not both.
I tried adding
but now success of course....I am missing something
Using mysql 4.1...
I am not even sure I can achive this in one query.
orders -> PK orders_id
Code: Select all
SELECT DAYNAME( o.date_end ) AS pd, count( * ) AS amount
FROM process op
LEFT JOIN orders o
USING ( orders_id )
WHERE op.field_name = 'product_id'
AND op.field_value = 50037
AND o.date_end IS NOT NULL
AND YEAR( o.date_end ) =2005
AND WEEK( o.date_end, 1 ) =45
GROUP BY pdI want to count only one of them not both.
I tried adding
Code: Select all
AND op.process_id = (SELECT MAX(process_id) FROM process WHERE `field_name` = 'product_id' AND `field_value` = 50037 )Using mysql 4.1...
I am not even sure I can achive this in one query.