T
Tom
Hi:
I’m having trouble with the following query…any suggestions?
* tblProposal is a linked table in SQL Server
* qryProposalFilter is a local query that limits the list of
ProposalID to the desired subset.
What I want to do is return the value of the field ContingencyGeneral
if the value is the same for all the proposals in the desired subset.
If there are different values, I want the word “Varies” to be
returned.
I’m opening a recordset in code and pulling out the returned value to
plug into a Word report.
Thru much trial and error, I came up with the following working
solution.
SELECT Count(*) AS N,
IIf([n]=1,(SELECT TOP 1 dbo_tblProposal.ContingencyGeneral FROM
dbo_tblProposal
INNER JOIN qryProposalFilter ON dbo_tblProposal.ProposalID =
qryProposalFilter.ProposalID,'Varies') AS MiscRate
FROM [SELECT DISTINCT dbo_tblProposal.ContingencyGeneral FROM
dbo_tblProposal
INNER JOIN qryProposalFilter ON dbo_tblProposal.ProposalID =
qryProposalFilter.ProposalID]. AS T;
However, it is slow when used over a WAN. Performance seems
acceptable when over a LAN.
Any idea’s on how I can speed up the overall process? Either changes
to the SQL or to the overall approach in code would be much
appreciated.
(oh - and I have to repeat this for about a dozen different fields -
so the performance hit is magnified)
Thanks
I’m having trouble with the following query…any suggestions?
* tblProposal is a linked table in SQL Server
* qryProposalFilter is a local query that limits the list of
ProposalID to the desired subset.
What I want to do is return the value of the field ContingencyGeneral
if the value is the same for all the proposals in the desired subset.
If there are different values, I want the word “Varies” to be
returned.
I’m opening a recordset in code and pulling out the returned value to
plug into a Word report.
Thru much trial and error, I came up with the following working
solution.
SELECT Count(*) AS N,
IIf([n]=1,(SELECT TOP 1 dbo_tblProposal.ContingencyGeneral FROM
dbo_tblProposal
INNER JOIN qryProposalFilter ON dbo_tblProposal.ProposalID =
qryProposalFilter.ProposalID,'Varies') AS MiscRate
FROM [SELECT DISTINCT dbo_tblProposal.ContingencyGeneral FROM
dbo_tblProposal
INNER JOIN qryProposalFilter ON dbo_tblProposal.ProposalID =
qryProposalFilter.ProposalID]. AS T;
However, it is slow when used over a WAN. Performance seems
acceptable when over a LAN.
Any idea’s on how I can speed up the overall process? Either changes
to the SQL or to the overall approach in code would be much
appreciated.
(oh - and I have to repeat this for about a dozen different fields -
so the performance hit is magnified)
Thanks