Re: Set a dinamic varable in query



I'm not sure that was the right answer to my question. But i tyr again.
I want to a column to desribe a hierarchy .

Here is my table:

F1 F2 F3(my new colonne)
10 text 10
null text 10
null tesxt 10
12 text 12
null tekxt 12
null tete 12
44 rwrw 44
null hhkjh 44
null tertre 44
........

"Hugo Kornelis" wrote:

> On Fri, 13 May 2005 04:48:02 -0700, CJ wrote:
>
> >Hello!
> >I wish to use a variable i a query that can change under execute.
> >
> >Here are some of my rows, i wish to make the f3 colonne
> >
> >F1 F2 F3(my new colonne)
> >10 text 10
> >null text 10
> >null tesxt 10
> >11 text 11
> >null tekxt 11
>
> Hi CJ,
>
> If these are all your columns, you are out of luck. A table in SQL
> Server has no implicit ordering. As far as SQL Server is concerned, the
> table above is exactly the same as this one:
>
> F1 F2 F3(my new colonne)
> null text 10
> 11 text 11
> null tesxt 10
> 10 text 10
> null tekxt 11
>
> (Note that I merely has some of the rows switch position).
>
> Your sample data indicates that you want to set F3 equal to F1 if it's
> not NULL, or equal to F1 from the "last" of the "previous" rows with F1
> not NULL otherwise. But since there is noting in the data to define
> "last" or "previous", this becomes an impossible task.
>
> If there is a way to distinguish "previous" and "last" rows from the
> data, then feel free to repost. The best way to do that would be to
> follow the guidelines in www.aspfaq.com/5006.
>
> Best, Hugo
> --
>
> (Remove _NO_ and _SPAM_ to get my e-mail address)
>
.