AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken problem mit komplizierter sql abfrage
Thema durchsuchen
Ansicht
Themen-Optionen

problem mit komplizierter sql abfrage

Ein Thema von polondo · begonnen am 9. Aug 2006 · letzter Beitrag vom 11. Aug 2006
 
omata

Registriert seit: 26. Aug 2004
Ort: Nebel auf Amrum
3.154 Beiträge
 
Delphi 7 Enterprise
 
#2

Re: problem mit komplizierter sql abfrage

  Alt 9. Aug 2006, 21:53
Hallo polondo,

vielleicht so...

SQL-Code:
SELECT 'productbookingpos & invoicepos', a.prod_id,
       DATEDIFF(day, a.expdate, b.expdate) tage,
       COALESCE(SUM(a.quantity), 0) - COALESCE(SUM(b.quantity), 0) ergebnis
FROM productbookingpos a
INNER JOIN invoicepos b
  ON a.prod_id = b.prod_id
     AND b.invalid = 0
WHERE a.invalid = 0
GROUP BY a.prod_id, a.expdate, b.expdate

UNION

SELECT 'nur productbookingpos',
       prod_id,
       NULL tage,
       COALESCE(SUM(quantity), 0) ergebnis
FROM productbookingpos a
WHERE invalid = 0
  AND NOT EXISTS (SELECT *
                  FROM invoicepos
                  WHERE prod_id = a.prod_id
                    AND invalid = 0)
GROUP BY prod_id, expdate

UNION

SELECT 'nur invoicepos',
       prod_id,
       NULL tage,
       COALESCE(SUM(quantity), 0) ergebnis
FROM invoicepos a
WHERE invalid = 0
  AND NOT EXISTS (SELECT *
                  FROM productbookingpos
                  WHERE prod_id = a.prod_id
                    AND invalid = 0)
GROUP BY prod_id, expdate
Gruss
Thorsten
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:50 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz