🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.vdbase.data.sql
Article #1038

Re: SUM(QUESTION)

#1038
From: Keith A. Towell
Date: Wed, 13 May 1998 00:00
51 lines
2057 bytes
Geoff,

That would only give me one sum.  I need all of the sums for a particular
country.

SELECT I.DIVISION, I.COUNTRY, SUM(I.AMOUNT WHERE I.W = "1"), SUM(I.AMOUNT
WHERE I.W = "2"), SUM(I.AMOUNT WHERE I.W = "3"),SUM(I.AMOUNT WHERE I.W =
"4") FROM INPUT I

...which is the more logical way of saying it.  I know the above code is not
correct, but you could do this xbase style using memory variables.

Keith

Geoff Wass wrote in message <35597071.447EAFE2@ibm.net>...
>Keith,
>
>Now that I think about, the Select should be changed, too if you use
>GROUP BY. If I recall any field used in GROUP BY must be listed
>explicitly.
>
>SELECT I.DIVISION, SUM(I.AMOUNT) FROM INPUT I, WORK W, COUNTRY C
>    WHERE I.DIVISION = W.DD AND I.COUNTRY = C.COUNTRY AND I.WORK =
>W.WORK
>    GROUP BY DIVISION
>
>or you could try:
>
>SELECT I.DIVISION, I.COUNTRY, SUM(I.AMOUNT) FROM INPUT I, WORK W,
>COUNTRY C
>    WHERE I.DIVISION = W.DD AND I.COUNTRY = C.COUNTRY AND I.WORK =
>W.WORK
>    GROUP BY DIVISION, COUNTRY
>
>Maybe none of these are correct, but I think you get the drift.
>
>--
>Geoff Wass
>Kuala Lumpur, Malaysia
>
>
>=============================================================
>Please respond to a newsgroup posting by posting a reply (not e-mail).
>In this way, all can help and all can learn!
>
>
>=============================================================
>Triumph is in the first syllable.
>
>
Technical Details
Message-ID: <6jcoho$d1v8@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <6j8ia7$9br11@forums.borland.com> <3557DBDA.C21AD80@ibm.net> <6j9l9f$9vp14@forums.borland.com> <35590D45.A88DECC4@ibm.net> <35597071.447EAFE2@ibm.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: ff5a1,d5546114e3a7f07c
X-Google-Attributes: gidff5a1,public
From: "Keith A. Towell" <katowell@1stConnect.com>
Subject: Re: SUM(QUESTION)
Date: 1998/05/13
Message-ID: <6jcoho$d1v8@forums.borland.com>
X-Deja-AN: 352955057
References: <6j8ia7$9br11@forums.borland.com> <3557DBDA.C21AD80@ibm.net> <6j9l9f$9vp14@forums.borland.com> <35590D45.A88DECC4@ibm.net> <35597071.447EAFE2@ibm.net>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.vdbase.data.sql