>
> hmm dun really understand ...
>
> ....
>
> i want to find all transactions from a item whose transaction's unit price
> column is more that 500. how can i do that?
>
I'd love to see some examples that use GROUP BY, could someone post an
example that uses the same ORM and shows all items and transaction count
that have transactions over 500.
I *guess* the SQL would look a little like:
SELECT items.*, SUM(tr.price) AS total, COUNT(tr.id) AS count
FROM items
JOIN transactions AS tr ON tr.item_id=items.id
GROUP BY items.id
HAVING SUM(tr.price)>500
I can construct this using $this->select()->join() etc... but how do I use
all the db_table_relationships?
We do this sort of thing all the time. We always want to know which customer
has:
- 0 payments
- a lot of payments (more than 5 a year)
- the oldest payment (using order by payment date DESC)
- all customers who made a payment more than a month ago.
- a total of all the payments made
examples of all, or some of the above would be wonderful!!
monk.e.boy
--
View this message in context: http://www.nabble.com/findDependentRowset---selects-tp23592902p23649506.html
Sent from the Zend DB mailing list archive at Nabble.com.
没有评论:
发表评论