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.
| Author |
Topic |
|
ossie1971
Starting Member
1 Post |
Posted - 2005-06-21 : 10:09:02
|
| HiFirstly 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 columnsvaluationID (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 thisvaluationID propertyID userID Valuation valDate1 1 1 100,000 24/04/20032 1 1 105,00, 25/04/20033 1 1 110,000 26/04/20034 2 1 100,000 24/04/20035 2 1 105,000 25/04/20036 3 2 110,000 26/04/20037 3 2 100,000 24/04/20038 3 2 105,000 25/04/2003Based 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 helpLeeHow 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. :) |
 |
|
|
|
|
|
|
|