Nigel, Thanks!
Mark On Wednesday 14 December 2005 09:42 am, nigel wood wrote: > Mark Phillips wrote: > >Flights > >+-----------+----------+----------+ > > > >| flight_id | data1_id | data2_id | > > > >+-----------+----------+----------+ > > > >| 1 | 1 | 1 | > >| 2 | 1 | 3 | > >| 3 | 1 | 1 | > >| 4 | 2 | 2 | > >| 5 | 2 | 3 | > >| 6 | 1 | 1 | > >| 7 | 1 | 1 | > >| 8 | 4 | 4 | > >| 9 | 1 | 2 | > >| 10 | 1 | 2 | > >| 11 | 1 | 1 | > > > >+-----------+----------+----------+ > > > >The data1_id and data2_id are indexes for the data recorded for that > > flight. > > > >I want to summarize the data. One such summary is to count the number of > >different data1_id's and data2_id's. For example: > > > >Flight Result Summary > > index: 1 2 3 4 > >data1_id 8 2 0 1 > >data2_id 5 3 2 1 > > select > sum(if(data1_id =1,1, 0)) as data1_id_1, sum(if(data1_id =2, 1, > 0)) as data1_id_2, etc , etc > sum(if(data2_id =1,1, 0)) as data2_id_1, sum(if(data2_id =2, 1, > 0)) as data2_id_2 etc, etc > from flights > > add composite indexes if required for speed. > > Nigel -- Mark Phillips [EMAIL PROTECTED] 602 524-0376 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]