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 |
|
potn1
Starting Member
33 Posts |
Posted - 2011-04-26 : 00:54:00
|
| I have a table in my database and I am extracting a query to display the person_id, appointment_date, amount_of_records. A person can have multiple appointment_dates per month and at each of these appointments the number_of_records varies. Basically I am looking for a sql statement where I can find the total amount_of_records per person_id for any given month. For example one person has 3 appointment_dates in the month of June. At these appointments they have 5, 10 and 15 records. Basically what I am looking for is a way to display in a table the total records per person which in this case would be 30. I believe I have to use some sort of aggregate function with a SUM and GROUP BY. Anyone have any suggestions? I’m not sure if this total should also just be displayed in another column?This statement below totals of the amount of records per person. Is there a way I can include a set of dates to get the total per records for a specific month per person?SELECT person_id, SUM(amount_of_records) FROM personGROUP BY amount_of_records |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
potn1
Starting Member
33 Posts |
Posted - 2011-04-26 : 11:12:32
|
| That is exactly what I was looking for, thanks a bunch!This can be marked as answered if needed. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|