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)
 Stuck with SQL2000 query/sp

Author  Topic 

ossie1971
Starting Member

1 Post

Posted - 2005-06-21 : 10:09:02
Hi

Firstly let me say that although I have been using basic data access techniques for a few years, once I get past something that access front end cannot handle I'm stuck!
I have been banging my head over this for a few days and was recommended here by a friend. Here's my situation:

I have a table that holds property valuations with the following columns

valuationID (pk, int, id)
valuation (money)
propertyID (int, this is the PK in the main property table)
userID (int, this is the PK in the main user table)
valDate (datetime)

The system is an estate management tool using VB.net & SQL 2000.
Within the system a single userID might have 2 or more propertyID's each with multiple entries in the valuation table.

something like this
valuationID propertyID userID Valuation valDate
1 1 1 100,000 24/04/2003
2 1 1 105,00, 25/04/2003
3 1 1 110,000 26/04/2003
4 2 1 100,000 24/04/2003
5 2 1 105,000 25/04/2003
6 3 2 110,000 26/04/2003
7 3 2 100,000 24/04/2003
8 3 2 105,000 25/04/2003

Based on the info in the table above I need to be able to show the current valuation of a users estate, in this instance userID 1 has 2 properties the current total value of these based on last valuation date is 215,000 (valuation fields in records 3 & 5 added together)

Any idea's how I can achieve this using either a stored procedure or a view or a combination of both.

Thanks in advance for any help

Lee

How do you know you can't swim until you have drowned

mr_mist
Grunnio

1870 Posts

Posted - 2005-06-21 : 11:30:35
SELECT SUM(valuation), userID, valdate from yourtable GROUP BY UserID, valdate

-------
Moo. :)
Go to Top of Page
   

- Advertisement -