Can parameter value depend on data field value? | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Can parameter value depend on data field value?

hi, i need your help… my case is, i need to print out a report with several funds. i need to sum out the total amount from that particular fund accordingly and display the value in table header.each fund’s subtotal is different. every page of the report can only consist of one fund. if the next record is another fund, then it will jump to the next page. problem: Can my subtotal change accordingly to the fund base on the fund name of the page.is it possible to make it in table header? if yes how? if no, is there anyway to make it in body section with the condition that i want to display this amount in the first line of every page ? hope that you can understand my question… thank you very much for your concern…….
Sounds like you need to use 2 querys to the database. Your first query should be a group by query. e.g. select fundname, sum(fundamount)
from funds
group by fundname
In your report you can parse through this query and display fund name and sumtotal wherever you like. Since you will have access to the fundname in your report page, you can then run another query to list the details of the fund.
select fundspecifics, fundamount
from funds
where fundname = @fundname I would say this is going to be more efficient than returning the entire result of all the funds for reporting purposes. Dave Hilditch
]]>