🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #1014

Combine two queries

#1014
From: Hs
Date: Tue, 06 Mar 2007 13:44
16 lines
1291 bytes

   I have two queries:

   1. SELECT SUM(BUY.WEIGHT), SUM(BUY.WEIGHT) * 100
    FROM BUY WHERE BUY.PAID = 'N' GROUP BY BUY.FARMERID


   2. SELECT FARMER.* FROM FARMER WHERE FARMER.ID IN 
    (SELECT BUY.FARMERID FROM BUY WHERE BUY.PAID = 'N' GROUP BY BUY.FARMERID)

  - In first query I have to use SUM(BUY.WEIGHT) twice. will it decrease performance?
   if yes how can I use it once?
  - Is there any way to combine thease two queries into one query? (their condition is same)

  Thanks.
Technical Details
Message-ID: <45ed7043$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news1.google.com!news.germany.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,fecb26f87dac9ab0,start
X-Google-Attributes: gid114a0e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Hs" <prg_stu@yahoo.com>
Sender: "Hs" <prg_stu@yahoo.com>
Reply-To: "Hs" <prg_stu@yahoo.com>
Subject: Combine two queries
Newsgroups: borland.public.interbase.sql
X-User-Info: 89.144.139.130     
X-Forwarded-For: 217.219.189.181
NNTP-Posting-Host: 207.105.83.66
Message-ID: <45ed7043$1@newsgroups.borland.com>
Date: 6 Mar 2007 05:44:35 -0800
X-Trace: newsgroups.borland.com 1173188675 207.105.83.66 (6 Mar 2007 05:44:35 -0800)
Lines: 16
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news1.google.com!news.germany.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail