From: Peter Brawley Date: October 4 2005 10:22pm Subject: Re: Query Question List-Archive: http://lists.mysql.com/mysql/189973 Message-Id: <43430088.2090602@earthlink.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Roy, >How do I set up a query whose output would look like this: >Tolerance PartA PartB PartC >1 10 12 6 >2 11 14 7 >3 13 16 7 >4 15 16 8 >5 18 17 10 One way is... SELECT tolerance, MAX(CONCAT(IF(Partname='A', Cycles, '' ))) AS PartA, MAX(CONCAT(IF(Partname='B', Cycles, '' ))) AS PartB, MAX(CONCAT(IF(Partname='C', Cycles, '' ))) AS PartC FROM table GROUP BY tolerance; PB ---- Roy Harrell wrote: >Suppose I have a simple table as follows: > >PartName Tolerance Cycles >A 1 10 >A 2 11 >A 3 13 >A 4 15 >A 5 18 >B 1 12 >B 2 14 >B 3 16 >B 4 16 >B 5 17 >C 1 6 >C 2 7 >C 3 7 >C 4 8 >C 5 10 > > >How do I set up a query whose output would >look like this: > >Tolerance PartA PartB PartC >1 10 12 6 >2 11 14 7 >3 13 16 7 >4 15 16 8 >5 18 17 10 > > >Thanks, > >Roy Harrell >Adaptive Equipment >352.372.7821 > > > > -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.344 / Virus Database: 267.11.9/118 - Release Date: 10/3/2005