List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:October 4 2005 10:22pm
Subject:Re: Query Question
View as plain text  
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

Thread
Query QuestionRoy Harrell4 Oct
  • Re: Query QuestionDavid Griffiths4 Oct
  • Re: Query QuestionSGreen4 Oct
  • Re: Query QuestionPeter Brawley5 Oct
RE: Query QuestionJacek Becla4 Oct
  • RE: Query QuestionSGreen4 Oct
RE: Query QuestionJacek Becla4 Oct
  • RE: Query QuestionRoy Harrell4 Oct