Embedded SELECT

Ivan Smahin Ivan_Smahin at valentina-db.com
Mon Oct 16 17:05:39 CDT 2006


On Oct 16, 2006, at 4:53 PM, Kem Tekinay wrote:

> Shouldn’t this code work?
>
> select tbl.repname as 'name', tbl.majorparty as 'party', sum(tbl.v)  
> from (
> select
>  votes as 'v', if(party='dem' or party='gop', name, 'other') as  
> 'repname',
>  if(party='dem' or party='gop', party, '---') as 'majorparty' from
> Candidates ) tbl group by tbl.repname, tbl.majorparty

I think it will not work currently.
But you can easy split it on two stage:

Create temporary table as first step and do GROUP BY on it then.

--
Best regards
Ivan Smahin





More information about the Valentina mailing list