Hi!
You can do this by using & and SELECT statements. Populate a string variable with the query like following:
lcstr=
select a1.id, a1.time as m1, 0 as m2, 0 as m3, ..... from MyTimes a1 into cursor tempcursor
union all
select a2.id, 0 as m1, a2.time as m2, 0 as m3, ..... from MyTimes a2
union all
select a3.id, 0 as m1, 0 as m2, a3.time as m3, ..... from MyTimes a3
.....
&lcstr
Next query is:
select id, max(m1), max(m2), max(m3), ..... from tempcursor group by id
Build it in the string and run it too using &. Instead of max() you can use sum() in case of negative values, it is slower, however.
Pretty pure crosstab, but in simple case it is just a 2 queries...
HTH.
>Hi readers!,
> Is it possible to create n sql columns for an specific field table, let me explain a little bit more:
>
> I have the next table:
> field -----value
> id ---- 1000
> time ---- 0700
> id ---- 1000
> time ---- 1700
> id ---- 1400
> ...and so on
>
>and I need the syntax for sql command that produces the next result set:
>
> id ------ m1 --- m2 --- m3 ... mn
> 1000 -- 0700 -- 1400 -- 1700 ...
>
>Best Regards
>Martin Alcaraz
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.comICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs
It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.