Comparison for Sorting
Above assumes that we have a function to compare tuples.
Needs to understand ordering on different data types.
E.g. a function tupCompare(r1,r2,f) (cf. C's strcmp )
- takes two tuples
r1 , r2 and a field name f
- returns negative value if
r1.f < r2.f
- returns positive value if
r1.f > r2.f
- returns zero value if
r1.f == r2.f
Can work on multiple attributes (sort on first, then second if equal, ...)
select * from Students
order by age desc, year_enrolled
|
|