Explanation:
Let the number of psychology books be 'x'.
and that of sociology books be 'y'.
x + y = 317 (given)
Number of sociology books sold was 89 less than that of psychology books.
y = x - 89
Which means,
x + x - 89 = 317
2x = 317 + 89
2x = 406
x = 406/2 = 203
y = 203 - 89 = 114
Hence, 203 psychology books and 114 sociology books were sold.