🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

How to query

#174
From: Hs
Date: Sat, 05 Jul 2008 13:44
17 lines
1093 bytes
This is my table:

CREATE TABLE "BUY" 
(
  "CUSTOMER_ID" INTEGRER,
  "WEIGHT" 	INTEGER,
  "BUY_DATE"	DATE
);

I want: SELECT "CUSTOMER_ID", SUM("WEIGHT" * CostA or CostB) TOTAL_COST 
            FROM BUY GROUP BY "CUSTOMER_ID";

The problem: I should use CostA when "BUY_DATE" is before 2000/10/10 and CostB when it is after 2000/10/10.
can I do it in one query? what is the best other way?

Thanks.
Technical Details
Message-ID: <486f7abd$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,19aface1effac68b,start
X-Google-Attributes: gid114a0e,domainid0,public,usenet
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: How to query
Newsgroups: borland.public.interbase.sql
X-User-Info: 80.191.190.94     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <486f7abd$1@newsgroups.borland.com>
Date: 5 Jul 2008 06:44:29 -0700
X-Trace: newsgroups.borland.com 1215265469 207.105.83.66 (5 Jul 2008 06:44:29 -0700)
Lines: 17
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail