How do I get data from multiple other entries in a database?
July 17, 2011 2:43 PM Subscribe
SQL help: I'm very new to SQL, and need to update one field with the maximum value of all entries in another field selected based on a shared value in a third field.
posted by agentofselection to computers & internet (12 answers total) 4 users marked this as a favorite
I have a table like this:
A |B |C
1 |5 |
1 |4 |
2 |0 |
2 |2 |
3 |3 |
3 |1 |
I need to update field C to contain the maximum value of field B for all entries that share the same value in field A.
A |B |C
1 |5 |5
1 |4 |5
2 |0 |2
2 |2 |2
3 |3 |3
3 |1 |3
I know I need to be doing an update on C and a select based on A and a max of B from that selection, or something, but I have no idea what the syntax for this should look like.
Relevant: I am trying to do this in Open Office Base.
I am totally new to SQL, and would do this in a spreadsheet program if I thought I could. My impression is that SQL is the right solution for this problem, and that I should probably learn it.