javauser
08-13-2008, 07:39 AM
Hi,
The below sql query which works correctly.But it only displays the value 'source' only once eventhough when the same value appears more than once.How can I make it to print for each and every value.I tried to remove 'first' clause for source column an error occurs as
You tried to execute a query that does not include the specified expression 'Source' as part of an aggregate function.
The concerned query is the last one.And DQ1,DQ2 are the first and second queries
SELECT estats.ID, eparams.Parameter as [SC], eprms.ParamValue as [SrcCode]
FROM eparams INNER JOIN (eprms INNER JOIN estats ON eprms.ID = estats.ID) ON eparams.ParamID = eprms.ParamID
WHERE (((eparams.Parameter)="srcCode"))
ORDER BY estats.ID, eparams.Parameter, eprms.ParamValue;
SELECT estats.ID, eparams.Parameter as [Don], eprms.ParamValue as [DonAmt]
FROM eparams INNER JOIN (eprms INNER JOIN estats ON eprms.ID = estats.ID) ON eparams.ParamID = eprms.ParamID
WHERE (((eparams.Parameter)="donAmt"))
ORDER BY estats.ID, eparams.Parameter, eprms.ParamValue;
select SC_NAMES.SC_Name as [Source],first(DQ1.SrcCode) as [Source Code],count(DQ1.[estats.ID]) as [Number of Donations],sum(DQ2.DonAmt) as [Donation Amount]
FROM (@Datalink.Query(1).Name@ DQ1 INNER JOIN @Datalink.Query(2).Name@ DQ2
ON DQ1.id=DQ2.id) LEFT OUTER JOIN SC_NAMES ON Mid(DQ1.SrcCode,1,2) = SC_NAMES.SC_CODE
Group By DQ1.SrcCode
The below sql query which works correctly.But it only displays the value 'source' only once eventhough when the same value appears more than once.How can I make it to print for each and every value.I tried to remove 'first' clause for source column an error occurs as
You tried to execute a query that does not include the specified expression 'Source' as part of an aggregate function.
The concerned query is the last one.And DQ1,DQ2 are the first and second queries
SELECT estats.ID, eparams.Parameter as [SC], eprms.ParamValue as [SrcCode]
FROM eparams INNER JOIN (eprms INNER JOIN estats ON eprms.ID = estats.ID) ON eparams.ParamID = eprms.ParamID
WHERE (((eparams.Parameter)="srcCode"))
ORDER BY estats.ID, eparams.Parameter, eprms.ParamValue;
SELECT estats.ID, eparams.Parameter as [Don], eprms.ParamValue as [DonAmt]
FROM eparams INNER JOIN (eprms INNER JOIN estats ON eprms.ID = estats.ID) ON eparams.ParamID = eprms.ParamID
WHERE (((eparams.Parameter)="donAmt"))
ORDER BY estats.ID, eparams.Parameter, eprms.ParamValue;
select SC_NAMES.SC_Name as [Source],first(DQ1.SrcCode) as [Source Code],count(DQ1.[estats.ID]) as [Number of Donations],sum(DQ2.DonAmt) as [Donation Amount]
FROM (@Datalink.Query(1).Name@ DQ1 INNER JOIN @Datalink.Query(2).Name@ DQ2
ON DQ1.id=DQ2.id) LEFT OUTER JOIN SC_NAMES ON Mid(DQ1.SrcCode,1,2) = SC_NAMES.SC_CODE
Group By DQ1.SrcCode