Mercurial > urweb
annotate tests/order_by.ur @ 1605:48eed6cf2be7
Fix bug in previous change
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 20 Nov 2011 20:46:28 -0500 |
parents | bacd0ba869e1 |
children |
rev | line source |
---|---|
adamc@230 | 1 table t1 : {A : int, B : string, C : float} |
adamc@230 | 2 table t2 : {A : float, D : int} |
adamc@230 | 3 |
adamc@230 | 4 val q1 = (SELECT * FROM t1 ORDER BY t1.A, t1.B) |
adamc@230 | 5 val q2 = (SELECT * FROM t1 GROUP BY t1.A ORDER BY t1.A, t1.B) |
adamc@230 | 6 val q3 = (SELECT t1.B FROM t1 |
adamc@230 | 7 UNION SELECT t1.B FROM t1 |
adamc@230 | 8 ORDER BY t1.B) |
adamc@234 | 9 |
adamc@234 | 10 val q4 = (SELECT t1.A, t2.D, t1.A < t2.D AS Lt |
adamc@234 | 11 FROM t1, t2 |
adamc@234 | 12 ORDER BY Lt) |
adamc@261 | 13 val q5 = (SELECT t1.A, t1.B, t2.D, t1.A < t2.D AS Lt |
adamc@234 | 14 FROM t1, t2 |
adamc@268 | 15 ORDER BY t1.A DESC, Lt ASC, t2.D DESC) |
adamc@261 | 16 |
adamc@261 | 17 |
adamc@261 | 18 datatype list a = Nil | Cons of a * list a |
adamc@261 | 19 |
adamc@261 | 20 val r1 : transaction (list string) = |
adamc@261 | 21 query q5 |
adamc@261 | 22 (fn fs acc => return (Cons (fs.T1.B, acc))) |
adamc@261 | 23 Nil |
adamc@261 | 24 |
adamc@261 | 25 val r2 : transaction string = |
adamc@261 | 26 ls <- r1; |
adamc@261 | 27 return (case ls of |
adamc@261 | 28 Nil => "Problem" |
adamc@261 | 29 | Cons (b, _) => b) |
adamc@261 | 30 |
adamc@261 | 31 val main : unit -> transaction page = fn () => |
adamc@261 | 32 s <- r2; |
adamc@261 | 33 return <html><body> |
adamc@261 | 34 {cdata s} |
adamc@261 | 35 </body></html> |