Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
12 records become 1 in horizontal
Message
From
28/09/2006 20:09:48
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
12 records become 1 in horizontal
Miscellaneous
Thread ID:
01158027
Message ID:
01158027
Views:
61
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
Next
Reply
Map
View

Click here to load this message in the networking platform