[SQL] SUM the result of a subquery.

2010-09-02 Thread negora
Hello: I've a question related to the combination of the SUM aggregate function and subqueries. Is it possible to SUM the resulting rows of a subquery? I'm explaining why I need this... I've a query like this: SELECT i.id_item, i.price, SUM (o.quantity), ROUND (SUM (o.quantity) * i.price, 2)

[SQL] SUM the result of a subquery.

2010-09-02 Thread negora
Hello: I've a question related to the combination of the SUM aggregate function and subqueries. Is it possible to SUM the resulting rows of a subquery? I'm explaining why I need this... I've a query like this: SELECT i.id_item, i.price, SUM (o.quantity), ROUND (SUM (o.quantity) * i.price, 2)

Re: [SQL] SUM the result of a subquery.

2010-09-02 Thread negora
Wow, I had no idea about this kind of SELECT _expression_. It works flawless!!! Thank you lots Jayadevan :) . On 02/09/10 14:28, Jayadevan M wrote: SELECT SUM ( (SELECT i.id_item, i.price, SUM (o.quantity), ROUND (SUM (o.quantity) * i.price, 2) AS cost FROM orders o JOIN items i ON i

Re: [SQL] all the table values equal

2010-09-21 Thread negora
I'm not sure if I understood you right, but it sounds similar to a case which I faced recently. Why not to use an inverse approach? In other words: trying to find those registries which hasn't got at least one value which differs from which you want to look for. How? Using the EXISTS function w

Re: [SQL] HowTo divide streetname from house-nr ?

2010-09-23 Thread negora
I guess that it's impossible to look for a solution which works on every existing case, specially if you're handling addresses from several countries. However, if you've certain control over the user inputs, maybe you could try replacing certain parts employing some kind of regular _expression_