I need help with ACCESS query. I am not at all good with access queries and am unable to figure this out even though it may have an easy solution.
There is an existing query designed by our company in a database. This query links different fields from 4 more queries and finally generates 16 columns as shown below. (I have also attached excel file with the same example as the text below is not aligned)
Name(1) ReportDate(2) TB(3) MV(4) NC(5) AI(6) SN(7) LN(8) SID(9) Country(10) PVS(11) BMV(12) Fund Code(13) MV by Fund code(14) Total TNAD(15) CUR(16)
ABC 3/31/2008 USD A CD UD na 0 $150.00 abcd $731.00 $745.00 CAD
ABC 3/31/2008 USD B CD UD na 0 $256.00 abcd $731.00 $745.00 CAD
ABC 3/31/2008 USD C CD UD na 0 $325.00 abcd $731.00 $745.00 CAD
XYZ 3/31/2008 CAD A CD UD na 0 $112.00 wxyz $387.00 $420.00 CAD
XYZ 3/31/2008 CAD B CD UD na 0 $275.00 wxyz $387.00 $420.00 CAD
PQR 3/31/2008 EUR C CD UD na 0 $60.00 pqrs $166.00 $200.00 CAD
PQR 3/31/2008 EUR A CD UD na 0 $72.00 pqrs $166.00 $200.00 CAD
PQR 3/31/2008 EUR B CD UD na 0 $34.00 pqrs $166.00 $200.00 CAD
In this example I am just showing 8 records, but in reality there usually about 4000 records and the number changes every day.
Now I am asked to design a query based on the query that gives the above results.
The 14th column (heading –MV by Fund code) actually sums up the market values in column 12 (BMV) that has same fund code in column 15. For example for fund code “abcd” the BMV are $150, $256 and $325 which sum upto $731 and hence this number shows up in column 14 against each record with “abcd” fund code.
Now there is a difference of $14 between column 15 (heading-Total TNAD) and column 14 (heading- MV by Fund Code) for fund code “abcd”. I am asked to design a query that will add records on the results generated above by the existing query.
The new record added should show the difference of $14 in column 12 and text “OTH” column 8 and column 9 and should show the fund code “abcd” . The values in remaining columns should be the same as the fund code “abcd”.
The above logic would then apply to funds “wxyz”, “pqrs” and so on
In this example the following three records should be added below the above 8 records with these details
ABC 3/31/2008 USD A OTH OTH na 0 $14.00 abcd $731.00 $745.00 CAD
XYZ 3/31/2008 CAD A OTH OTH na 0 $33.00 wxyz $387.00 $420.00 CAD
PQR 3/31/2008 EUR B OTH OTH na 0 $34.00 pqrs $166.00 $200.00 CAD
I guess this would require coding in SQL. But I am unable to do so.
Any help is highly appreciated
Thanks,
Peace
There is an existing query designed by our company in a database. This query links different fields from 4 more queries and finally generates 16 columns as shown below. (I have also attached excel file with the same example as the text below is not aligned)
Name(1) ReportDate(2) TB(3) MV(4) NC(5) AI(6) SN(7) LN(8) SID(9) Country(10) PVS(11) BMV(12) Fund Code(13) MV by Fund code(14) Total TNAD(15) CUR(16)
ABC 3/31/2008 USD A CD UD na 0 $150.00 abcd $731.00 $745.00 CAD
ABC 3/31/2008 USD B CD UD na 0 $256.00 abcd $731.00 $745.00 CAD
ABC 3/31/2008 USD C CD UD na 0 $325.00 abcd $731.00 $745.00 CAD
XYZ 3/31/2008 CAD A CD UD na 0 $112.00 wxyz $387.00 $420.00 CAD
XYZ 3/31/2008 CAD B CD UD na 0 $275.00 wxyz $387.00 $420.00 CAD
PQR 3/31/2008 EUR C CD UD na 0 $60.00 pqrs $166.00 $200.00 CAD
PQR 3/31/2008 EUR A CD UD na 0 $72.00 pqrs $166.00 $200.00 CAD
PQR 3/31/2008 EUR B CD UD na 0 $34.00 pqrs $166.00 $200.00 CAD
In this example I am just showing 8 records, but in reality there usually about 4000 records and the number changes every day.
Now I am asked to design a query based on the query that gives the above results.
The 14th column (heading –MV by Fund code) actually sums up the market values in column 12 (BMV) that has same fund code in column 15. For example for fund code “abcd” the BMV are $150, $256 and $325 which sum upto $731 and hence this number shows up in column 14 against each record with “abcd” fund code.
Now there is a difference of $14 between column 15 (heading-Total TNAD) and column 14 (heading- MV by Fund Code) for fund code “abcd”. I am asked to design a query that will add records on the results generated above by the existing query.
The new record added should show the difference of $14 in column 12 and text “OTH” column 8 and column 9 and should show the fund code “abcd” . The values in remaining columns should be the same as the fund code “abcd”.
The above logic would then apply to funds “wxyz”, “pqrs” and so on
In this example the following three records should be added below the above 8 records with these details
ABC 3/31/2008 USD A OTH OTH na 0 $14.00 abcd $731.00 $745.00 CAD
XYZ 3/31/2008 CAD A OTH OTH na 0 $33.00 wxyz $387.00 $420.00 CAD
PQR 3/31/2008 EUR B OTH OTH na 0 $34.00 pqrs $166.00 $200.00 CAD
I guess this would require coding in SQL. But I am unable to do so.
Any help is highly appreciated
Thanks,
Peace