Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
12 records become 1 in horizontal
Message
De
28/09/2006 20:16:57
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
28/09/2006 20:09:48
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01158027
Message ID:
01158029
Vues:
25
>Hi,
>
>I have mytable
>
>yearmonth
>200609
>200608
>200607
>200606
>200605
>200604
>200603
>200602
>200601
>200512
>200511
>200510
>
>to get brand newtable with 12 fields:
>
>yearmonth1 yearmonth2 yearmonth3 yearmonth4 yearmonth5 yearmonth6 yearmonth7
>200510 200511 200512 200601 200602 200603 200604
>
>yearmonth8 yearmonth9 yearmonth10 yearmonth11 yearmonth12
>200605 200606 200607 200608 200609
>
>I tried this
>
>select iif(yearmonth=200510,200510) as yearmonth1,
>iif(yearmonth=200511,200511) as yearmonth2,
>iif(yearmonth=200512,200512) as yearmonth3,
>iif(yearmonth=200601,200601) as yearmonth4,
>iif(yearmonth=200602,200602) as yearmonth5,
>iif(yearmonth=200603,200603) as yearmonth6,
>iif(yearmonth=200604,200604) as yearmonth7,
>iif(yearmonth=200605,200605) as yearmonth8,
>iif(yearmonth=200606,200606) as yearmonth9,
>iif(yearmonth=200607,200607) as yearmonth10,
>iif(yearmonth=200608,200608) as yearmonth11,
>iif(yearmonth=200609,200609) as yearmonth12
>from mytable into cursor newtable
>
>
>it works but not dynamic if the yearmonth changes, I have to recode my
>SQL, can someone assist to do it without worry about any yearmonth date changed.
>
>TIA

You can get "200511", etc. as an expression as follows:
ldDate = date(2005, 11, 1)
? left(dtos(gomonth(ldDate, 3)), 6) && As string
? val(left(dtos(gomonth(ldDate, 3)), 6)) && As numeric
By the way, the iif(), as posted, would give an error message, since there are only two parameters. Probably there is a third parameter which you forgot to post.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform