Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to change columns to rows in SELECT ?
Message
 
 
À
19/04/2001 15:35:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00497538
Message ID:
00497554
Vues:
11
>My table contains a list of shows with showtimes (see below).
>cCode cName cDate1, cDate2, cDate3, cDate4, cDate5, cDate6
>
>I want to know how can I offer in a combobox the list of
>dates for a selected show. In other words, I want to transpose
>the columns in rows (like below).
>
>for cCode="ABC" the result must be:
>cDate1
>cDate2
>cDate3
>cDate4
>cDate5
>cDate6
>
>What is the best way to do that?

I would actually normalize the table where you have 1 Date field and have a row for each date available for cCode.

Otherwise, you can try:
select cDate1 cShowDate from table1 where cCode = "ABC" ;
  union ;
select cDate2 cShowDate from table1 where cCode = "ABC" ;
  union ;
select cDate3 cShowDate from table1 where cCode = "ABC" ;
  union ;
select cDate4 cShowDate from table1 where cCode = "ABC" ;
  union ;
select cDate5 cShowDate from table1 where cCode = "ABC" ;
  union ;
select cDate6 cShowDate from table1 where cCode = "ABC" ;
order by 1
Mark McCasland
Midlothian, TX USA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform