🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #1892

Using a parameter multiple times

#1892
From: Freshy
Date: Tue, 13 Jan 2004 01:33
33 lines
1710 bytes
Hello,

I have a query to run against an Access 2000 database for a report where I
need to use a parameter twice.  For example:

SELECT
   a.[Name],
   a.[StartDate],
   a.[EndDate],
   a.[Hours],
   (SELECT SUM([Hours]) FROM [ATable] AS b WHERE b.[StartDate] >= :SDate AND
b.[EndDate] <= :EDate) AS Total
FROM [ATable] AS a
WHERE a.[StartDate] >= :SDate AND a.[EndDate] <= :EDate ;

I know that ADO has a problem with this, so I tried a couple of variations:

SELECT
   a.[Name],
   a.[StartDate],
   a.[EndDate],
   a.[Hours],
   :SDate AS PSDate,
   :EDate AS PEDate,
   (SELECT SUM([Hours]) FROM [ATable] AS b WHERE b.[StartDate] >= PSDate AND
b.[EndDate] <= PEDate) AS Total
FROM [ATable] AS a
WHERE a.[StartDate] >= PSDate AND a.[EndDate] <= PEDate ;

Unfortunately, this did not work.  Does anyone know of a way around this?

Thanks,
Ken
Technical Details
Message-ID: <40034ae2$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,1641a77b6273a1af,start
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2004-01-12 17:39:54 PST
From: "Freshy" <_REMOVE_THIS_freshy_s@hotmail.com>
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Using a parameter multiple times
Date: Mon, 12 Jan 2004 19:33:19 -0600
Lines: 35
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 65.123.110.23
Message-ID: <40034ae2$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1073957602 65.123.110.23 (12 Jan 2004 17:33:22 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail