🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Percentage calculation with sql in one pass

#68
From: Gary White [dBVIPS]
Date: Fri, 09 Apr 1999 00:00
21 lines
1102 bytes
On Thu, 8 Apr 1999 14:35:03 +0200, Klaas Wolters wrote:

> Select Type, Count(P1.Id)/Count(p2.Id) *100 as Percentage
> From
>   Patient p1,
>   Patient p2
> Where p1.Id = p2.Id
> Group by Type
> 
> But te second count gives the same results as the first count . 

Of course it will.  You are only selecting records where both are
equal, so there is no possibility of the counts being different.

Look at a LEFT OUTER JOIN to include unmatched rows.



Gary White [dBVIPS]
Some dBase stuff at:
http://www.apptools.com/dbase
Technical Details
Message-ID: <370d8e8a.11512199@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7ei7k7$1i612@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: ff5a1,8f161b4a65d9c69a
X-Google-Attributes: gidff5a1,public
From: Gary@no-email.please (Gary White [dBVIPS])
Subject: Re: Percentage calculation with sql in one pass
Date: 1999/04/09
Message-ID: <370d8e8a.11512199@forums.borland.com>
X-Deja-AN: 464320174
Content-Transfer-Encoding: 7bit
References: <7ei7k7$1i612@forums.borland.com>
Content-Type: text/plain; charset=us-ascii
Organization: Just Me
Mime-Version: 1.0
Reply-To: reply@newsgroup
Newsgroups: borland.public.vdbase.data.sql