I have the following situation on my database:
id: | second id: | value
Row 1: 1 | 1 | 123
Row 2: 1 | 2 | 234
Row 3: 1 | 3 | 456
Row 4: 2 | 1 | 987
Row 5: 2 | 2 | 876
Row 6: 2 | 3 | 765
Row 7: 3 | 1 | 345
Row 8: 3 | 2 | 678
Row 9: 3 | 3 | 543
Row 10: 4 | 1 | 345
...
For each id I have 3 second ids, they are always 1,2 and 3.
What I need to do is get the average of this 3 values (contemplating the 3 valus for id) and get the average of them. I need to do this with a long table (I was wondering about creating a specific view to do this).
Any help will be welcome.
(Sorry for my question, but i really begginer on SQL Server)
Just use AVG and group by each id only.