List:General Discussion« Previous MessageNext Message »
From:Baron Schwartz Date:April 20 2007 12:52pm
Subject:Re: How could write this SQL
View as plain text  
Hi,

wang shuming wrote:
> Hi,
> How could
> select
>    row1 a1,b1.qty, b2.qty, b3.qty
>    row2 a2,b1.qty, b2.qty, b3.qty
>    row3 a3,b1.qty, b2.qty, b3.qty
>     ...
> from a table :
> 
>     row1  a1,b1,qty
>     row2  a1,b2,qty
>     row3  a1,b3,qty
>     row4  a2,b1,qty
>     row5  a2,b2,qty
>     row6  a2,b3,qty
>     row7  a3,b1,qty

I think you are describing a cross-tabulation (aka pivot table).  You can do this with
joins, though this particular case looks tricky.  There is a good article on
cross-tabulations here:

http://www.onlamp.com/pub/a/onlamp/2003/12/04/crosstabs.html

Baron
Thread
How could write this SQLwang shuming20 Apr
  • Re: How could write this SQLBaron Schwartz20 Apr
    • RE : How could write this SQLJacques Brignon20 Apr
      • Error: Duplicate entry '0' for key 'PRIMARY'sam rumaizan2 Mar
Re: Error: Duplicate entry '0' for key 'PRIMARY'sam rumaizan2 Mar
Re: Error: Duplicate entry '0' for key 'PRIMARY'sam rumaizan2 Mar
  • Re: Error: Duplicate entry '0' for key 'PRIMARY'Darryle Steplight2 Mar
    • Re: Error: Duplicate entry '0' for key 'PRIMARY'sam rumaizan2 Mar
  • drop down menu to a tablesam rumaizan3 Mar
    • Information missing (was: Re: drop down menu to a table)Joerg Bruehe3 Mar