I have a SQL table
like this:
pr_Key | fr_Key | attr_1 | attr_2 |
---|---|---|---|
p_1 | f_1 | 100 | 150 |
p_2 | f_1 | 150 | 200 |
p_3 | f_1 | 200 | 250 |
p_4 | f_2 | 100 | 150 |
p_5 | f_2 | 150 | 200 |
p_6 | f_2 | 200 | 250 |
But, I only want to select
all the minimum
and maximum
for attr_1
and attr_2
of fr_Key
just like this:
| pr_Key | fr_Key | attr_1 | attr_2 |
| ------ | ------ | ------ | ------ |
| p_1 | f_1 | 100 | 150 | <-- the minimum values of f_1
| p_3 | f_1 | 200 | 250 | <-- the maximum values of f_1
| p_4 | f_2 | 100 | 150 | <-- the minimum values of f_2
| p_6 | f_2 | 200 | 250 | <-- the maximum values of f_2