Thanks for the reply. I know it sounds confusing. Sorry.
So you get one row back for each Sentiment across all UserID's? Or will you only do this for one UserID at a time?[/B]
There are three possible options for sentiment. I want a summary, so I need only three records. Here's an example:
The 3 possible options are:
Bullish
Bearish
Neutral
For each, I need to know the number of people that have that sentiment. For example, 10 people Bullish, 22 Bearish, 4 Neutral. The total number of people (i.e. 10+22+4 = 36) would also be the number of records found in the CurrentForecast table. This makes sence since you can only be one of the three options, but not more than one at a time. So I would need a count of the number of people that are Bullish, Bearish and Neutral.
For example:
Sentiment---Number
Bullish 10
Bearish 22
Neutral 4
Taking the query a bit further, for each person I need a SUM of their points from the forecasthistory table, linking by userid.
For example:
Sentiment---Number---History
Bullish 10--175.12
Bearish 22--225.98
Neutral 4--125.28
So at this point I have three records, Bullish, Bearish and Neutral. For each record I have counted the number of people that are of that sentiment, and I have totaled their points from the ForecastHistory table.
The last piece of data I need is a total of their current forecast. The CurrentForecast table contains their current sentiment (i.e.Bullish, Bearish, Neutral) along with the value of the Dow, S&P and Nasdaq at the point they established that sentiment. Since I know what their sentiment was at the time I recorded the values for the Dow, Nasdaq and S&P, I need to determine what the change has been since then. The current value of the Dow, Nasdaq and S&P are stored in the LastUpdated table. This is a one record table, and it simply stores the lastupdate time, along with the current values of the indices.
If you were Bearish and the Dow went down, you earned positive points (CurrentForecast.CurrentDow-LastUpdated.CurrentDow). If you were Bullish, you would have a negative point value. So I would have to reverse the calculation: (LastUpdated.CurrentDow-CurrentForecast.CurrentDow).
So I need to sum this data in my query. I want to add up the points for the current Bulls, Bears and Neutral people. The final result would look something like this.
Sentiment---Number---History---Current
Bullish 10--175.12---987.45
Bearish 22--225.98---456.98
Neutral 4--125.28---345.76
I really appreciate the help. I hope this clarifies the situation a bit more.
Thanks again.