Announcement

Collapse
No announcement yet.

Summe in Zellen

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Summe in Zellen

    Moin, Bin ein Anfänger, also sorry für meine Frage.

    Ich habe eine Tabelle, wie folgt:
    CREATE TABLE summary(
    Minimum INT,
    Maximum INT,
    Summe INT,
    Durchschnitt INT
    );


    Nun möchte ich dass die erste Zeile das Minimum, Maximum etc. eines bestimmten Bereiches einer anderen Tabelle / Spalte als Einträge hat.

    INSERT INTO summary(
    Minimum,
    Maximum,
    Summe,
    Durchschnitt
    )
    VALUES
    (MIN(Amount),max(Amount),sum(Amount),avg(Amount));

    Die Formel oben (ohne Bedingung) funktioniert nict.

    Könnt ihr mir helfen???

    Danke & Gruss
    Szymon


  • #2
    NSERT INTO summary(
    Minimum,
    Maximum,
    Summe,
    Durchschnitt
    )
    VALUES
    (select min(Feld) from tabelle,....
    Christian

    Comment


    • Szymon
      Szymon commented
      Editing a comment
      Hi Christian,
      Danke für Deine Antwort.
      Ich habe folgendes geschrieben:

      INSERT INTO summary(
      ** *Minimum,
      ** *Maximum,
      ** *Summe,
      ** *Durchschnitt
      )
      VALUES*
      (
      select MIN(Amount) from PV,
      select MAX(Amount) from PV,
      select SUM(Amount) from PV,
      select AVG(Amount) from PV
      );

      und bekam folgende Fehlermeldung:
      Msg 156, Level 15, State 1, Line 60
      Incorrect syntax near the keyword 'select'.
      Msg 156, Level 15, State 1, Line 61
      Incorrect syntax near the keyword 'select'.
      Msg 156, Level 15, State 1, Line 62
      Incorrect syntax near the keyword 'select'.
      Msg 156, Level 15, State 1, Line 63
      Incorrect syntax near the keyword 'select'.
      Msg 102, Level 15, State 1, Line 64
      Incorrect syntax near ')'.

      Woran liegt es?

  • #3
    Schreibe keine Kommentare, sondern eine Antwort.
    Wenn alles aus eine Tabelle kommt, sollte

    VALUES
    (
    select MIN(Amount) ,MAX(Amount), SUM(Amount) , AVG(Amount) from PV
    );
    Was die * in dem SQL bedeuten sollen weiß ich nicht

    Welche Datenbank?

    https://stackoverflow.com/questions/...es-select-from
    Christian

    Comment


    • #4
      Danke! It works now

      Comment

      Working...
      X