PDA

View Full Version : AS Clause und Where Abfrage in SQL



Miller8888
04-09-07, 14:00
Hallo,
ich möchte in SQL fünf Spalten mit Concat zu einem neuen Feld zusammenfügen. Dieses neue Hilfsfeld möchte ich in einer where Clause mit einer Bildschirmeingabe vergleichen. Ich bekomme einen SQL Fehler, der mir sagt, dass das Feld SQLArtikel nicht in den Tabellen existiert. Ist klar, dieses ist nämlich das Hilfsfeld. Wie muss ich die SQL-Anweisung abändern ? Danke für eure Hilfe.

c/execsql
c+ declare artikel cursor for
c+ SELECT
c+ aufpop.aparti concat
c+ aufpop.apfonr concat
c+ aufpop.apvkbr concat
c+ aufpop.apeauf concat
c+ aufpop.apfarb as SQLArtikel,
c+ aufpop.apkdnr,
c+ aufpop.apkabz,
c+ aufkop.akltkw,
c+ aufkop.akltkj,
c+ aufkop.akabnr,
c+ aufkop.akstat
c+ FROM aufkop
c+ leftouterjoin aufpop
c+ on aufkop.akabnr = aufpop.apabnr
c+ where SQLArtikel >= :b#artikel
c+ and akatyp ='N'
c+ and akkzae ='N'
c+ and apstat <>'9'
c+ orderby akltkj, akltkw, akstat
c+ forfetchonly
c/end-exec

mk
04-09-07, 15:59
hallo,

ích meine das Du das Feld bei dem where auch mit concat
zusammenbasteln musst.

gruss
michael

Fuerchau
04-09-07, 17:30
Man kann auch Tableexpression nehmen:

with
mytable as (
:
:
)
select * from mytable
where SQLArtikel = : Hostvar