Herausforderung für die SQL-Spezis
- Dieses Thema hat 2 Antworten und 1 Teilnehmer, und wurde zuletzt aktualisiert vor 13 Jahre, 12 Monaten von
Anonym.
-
AuthorPosts
-
5. Oktober 2009 um 12:33 Uhr #4052
AnonymInaktivHi@all,
ich bräuchte einen SQL, der mir die Ergebnisliste eben nicht als Liste sondern als konkatenierten String ausgibt.
Also eben nicht
FELD
—-
A
B
Csondern
FELD
—-
ABCProblem; ich weiss nicht, wie viele Ergebnisse zur WHERE-Bed. passen 🙁
Quasi rekursives SQL nicht nach unten sondern nach rechts…Danke&Grüsse
Alexander
6. Oktober 2009 um 6:25 Uhr #4217
AnonymInaktivWenn Du eine Tabelle T1 hast mit dem Beispielinhalt:
feld
—-
aa
bb
cc
dddann ist das Ergebnis dieser Query ein
conc                                         Â
——————————————————————-
aabbccdd                                     Âwith cte ( act, conc ) as                              Â
                                               Â
( s elect   feld as act , cast(feld as varchar(1000)) as conc from t1 a
   where not exists ( s elect * from t1 x where x.feld <a.feld )    Â
union all                                         Â
s elect  a.feld as act , conc !! a.feld as conc             Â
from t1 a, cte b                                    Â
where a.feld > cte.act                                Â
and not exists ( s elect * from t1 x where x.feld <a.feld and x.feld>cte.act))
                                               Â
s elect    conc from cte                             Â
order by conc desc fetch first row only                     Â6. Oktober 2009 um 6:42 Uhr #4340
AnonymInaktivMoin Uli,
ich habs gestern Abend auch noch hinbekommen; auch mit rek.SQL. Allerdings hats für die elegante Tour in einem SQL dann doch nicht gelangt.
Danke!
Alexander -
AuthorPosts
You must be logged in to reply to this topic.