Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Sum(TableName.FieldName) AS [Sum Of FieldName]

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-06-02 : 07:20:25
James writes "right, so I'm new at this, and for the first time I've had to construct the total value of combined fields, based on a relationship from its parenttable

here is the result (which works fine in a query, but I have no idea how to translate this to asp - and yes, i know you don't answer asp questions, however, its more of a sql syntax question, and not directly related to either access or ms-sql).

SELECT DISTINCTROW k_harvesttodate.lid, j_harvestLocation.lid, Sum(k_harvesttodate.lharvest) AS [Sum Of lharvest]
FROM j_harvestLocation INNER JOIN k_harvesttodate ON j_harvestLocation.lid = k_harvesttodate.lid
GROUP BY k_harvesttodate.lid, j_harvestLocation.lid
HAVING ((([where k_harvesttodate].[lid])=[j_harvestLocation].[lid]));

Puh leeeez hep me :("

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2004-06-02 : 14:45:17
So, you're saying that the SQL syntax works fine, for example if you run it in Query Analyzer you get the results you want? And you just want to know how to get that to work from an ASP page? You'll want to look for information on using ADO Recordset and Connection objects. Ideally, you would put the SQL syntax into a stored procedure (CREATE PROCEDURE...) and then call the stored procedure from your ASP code, pulling the results back into an ADO Recordset object. Then you can iterate through the recordset to display the results on your web page. Here is one of many links to articles on using ADO Recordsets in ASP: http://www.4guysfromrolla.com/webtech/faq/Databases/faq4.shtml

HTH

--------------------------------------------------------------
Find more words of wisdom at [url]http://weblogs.sqlteam.com/markc[/url]
Go to Top of Page
   

- Advertisement -