Many thanks for the query. It works ;)
Willy
On Fri, 2009-09-04 at 08:09 +0200, Wolfgang Schaefer wrote:
> sangprabv wrote:
> > I have these query:
> > SELECT SUM(price)*0.5 AS price1 FROM table WHERE partner = 'A';
> > SELECT SUM(price)*0.65 AS price2 FROM table WHERE partner = 'B';
> > Is it possible to make the queries into 1 single query? How to make it
> > happen? Many thanks for helps.
> >
> >
> >
> > Willy
> >
> >
> >
> You can group by partners and then calculate the price for the certain
> partner, if that is what you want.
>
> SELECT partner, IF(partner = 'A', sum(price)*0.5, '-') as price1,
> IF(partner = 'B', sum(price)*0.65, '-')
> as price2
> FROM table
> WHERE partner IN ('A', 'B')
> GROUP BY partner;
>
> cheers,
> wolfgang
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[email protected]