CR8.5, SQl Server 2k.
I'm trying to put a report together that shows Variances.
There is a Variance Table and Linked to it is a ItemAgreement Table via left outer join on Item
The ItemAgreement has Item and AgreementType in it. A Item can have many agreement types.
Agreement TYpe is also a parameter.
I only want to use the AgreementType table as a 'Filter'. i.e. It need to show Variances for all items that have a specifc agreementtype.
Sample data
Variance table
Key Item date Amount
1 a 01/07/04 10
2 b 01/08/04 12
3 b 01/07/04 8
4 c 01/07/04 9
ItemAgreementTable
Item Agreementtype
a 966
a 006
a 966
b 966
b 006
Senario 1
AgreementTYpe = '*' (Any Item, not limited by the ItemAgreementTable) and date=01/07/04
Results wanted
Key
1
3
4
Senario 2
AgreementType ='966'(Only Items with a Agreement Type of '966') and date=01/07/04
Items to filter on is 'a' and 'b'
Results wanted
key
1
3
I have complete flexability in designing the tables/views/sp in the db.
I am struggling with a few issues.
I do not what to create duplicate records for the variance table as I'll be subtotaling later on in the report when I start to group.
I need to return distict Items from the AgreementType table, but I need to also pass the Agreement TYpe parameter. (otherwise a View with a select distict would have been easy!).
Also if '*' is used for agreementtype, then I do not want the ItemAgreement table to filter the variance data.
Does anyone have any suggestions on how to handle this problem thats also fast?
Is a stored proc the way to go?
Thanks
I'm trying to put a report together that shows Variances.
There is a Variance Table and Linked to it is a ItemAgreement Table via left outer join on Item
The ItemAgreement has Item and AgreementType in it. A Item can have many agreement types.
Agreement TYpe is also a parameter.
I only want to use the AgreementType table as a 'Filter'. i.e. It need to show Variances for all items that have a specifc agreementtype.
Sample data
Variance table
Key Item date Amount
1 a 01/07/04 10
2 b 01/08/04 12
3 b 01/07/04 8
4 c 01/07/04 9
ItemAgreementTable
Item Agreementtype
a 966
a 006
a 966
b 966
b 006
Senario 1
AgreementTYpe = '*' (Any Item, not limited by the ItemAgreementTable) and date=01/07/04
Results wanted
Key
1
3
4
Senario 2
AgreementType ='966'(Only Items with a Agreement Type of '966') and date=01/07/04
Items to filter on is 'a' and 'b'
Results wanted
key
1
3
I have complete flexability in designing the tables/views/sp in the db.
I am struggling with a few issues.
I do not what to create duplicate records for the variance table as I'll be subtotaling later on in the report when I start to group.
I need to return distict Items from the AgreementType table, but I need to also pass the Agreement TYpe parameter. (otherwise a View with a select distict would have been easy!).
Also if '*' is used for agreementtype, then I do not want the ItemAgreement table to filter the variance data.
Does anyone have any suggestions on how to handle this problem thats also fast?
Is a stored proc the way to go?
Thanks