Einzelnen Beitrag anzeigen

Delphi.Narium

Registriert seit: 27. Nov 2017
2.434 Beiträge
 
Delphi 7 Professional
 
#17

AW: Access SQL Query optimieren?

  Alt 16. Jan 2024, 17:38
SQL-Code:
create view v_Sinnvollername as
select
  BestDocErfNr,
  BestDocDatum,
  BestDocLiefNr,
  BestDocKurzbez,
  BestPosAusstand,
  BestPosArtNr,
  BestPosBestNr,
  BestposName1,
  BestPosEPreis,
  ArtAltArtNr
from
(
  (
    select
      BestDocID,
      BestDocErfNr,
      BestDocDatum,
      BestDocLiefNr,
      BestDocKurzbez
    from BestDok
    where BestDocOptGeliefert = false
      and BestDocType = 0
  ) A
  inner join
  (
    select
      BestPosArtNr,
      BestPosAusstand,
      BestPosArtNr,
      BestPosBestNr,
      BestposName1,
      BestPosEPreis
    from BestPos
    where BestPosAusstand > 0
  ) U on A.BestDocID = U.BestPosDocID
  inner join
  (
    select
      ArtNr,
      ArtAltArtNr
    from sArtikel
  ) L on U.BestPosArtNr = L.ArtNr
)
Im SQL dann "nur noch"

select * from v_Sinnvollername where BestPosArtNr = :ArtNr order by BestDocErfNr asc

Hoffentlich hab' ich da jetzt keine gravierenden Fehler eingebaut.
  Mit Zitat antworten Zitat