reshaping challenge

reshaping challenge

am 12.04.2010 17:11:01 von Mitchell Maltenfort

I have a table with two columns, ID and order. Each ID can be
repeated up to 16 timers.

I need to reshape it so that I have one row per ID, and columns
order1, order 2,...order 16, and one number that lists how many orders
there actually were.

No this is not a homework assignment. I'm trying to make sense out of
a legacy project.

Can someone help me out?

Thanks!

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: reshaping challenge

am 13.04.2010 11:51:07 von Johan De Meersman

--00504502984359df5504841b33e9
Content-Type: text/plain; charset=ISO-8859-1

Are you quite sure there can never be more than 16 orders per ID ?

The form your table is in now is actually the preferred form. It's called an
associative table, and logic suggests that it sits between a table that
holds more info on the IDs, and a table that holds more info on the orders.


On Mon, Apr 12, 2010 at 5:11 PM, Mitchell Maltenfort wrote:

> I have a table with two columns, ID and order. Each ID can be
> repeated up to 16 timers.
>
> I need to reshape it so that I have one row per ID, and columns
> order1, order 2,...order 16, and one number that lists how many orders
> there actually were.
>
> No this is not a homework assignment. I'm trying to make sense out of
> a legacy project.
>
> Can someone help me out?
>
> Thanks!
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/mysql?unsub=vegivamp@tuxera.be
>
>


--
Bier met grenadyn
Is als mosterd by den wyn
Sy die't drinkt, is eene kwezel
Hy die't drinkt, is ras een ezel

--00504502984359df5504841b33e9--