summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2010-03-16 15:54:35 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2010-03-16 15:54:35 -0400
commita33b1fdbf6ff02d806ac5c563f9274abc57b6a43 (patch)
tree9d33fe703a729a1a6e1317fea053f4a3a646cf52 /tests
parent2bdffddbb847cbd620b8be911a1c1cb229187fc2 (diff)
COUNT(col)
Diffstat (limited to 'tests')
-rw-r--r--tests/agg.ur19
-rw-r--r--tests/agg.urp4
2 files changed, 9 insertions, 14 deletions
diff --git a/tests/agg.ur b/tests/agg.ur
index 7e091060..55e22c28 100644
--- a/tests/agg.ur
+++ b/tests/agg.ur
@@ -1,22 +1,13 @@
table t1 : {A : int, B : string, C : float}
-table t2 : {A : float, D : int}
+table t2 : {A : float, D : int, E : option string}
val q1 = (SELECT COUNT( * ) AS X FROM t1)
val q2 = (SELECT AVG(t1.A) AS X FROM t1)
val q3 = (SELECT SUM(t1.C) AS X FROM t1)
val q4 = (SELECT MIN(t1.B) AS X, MAX(t1.A) AS Y FROM t1)
-
-(*val q5 = (SELECT t1.A FROM t1 GROUP BY t1.B)*)
val q5 = (SELECT SUM(t1.A) AS X FROM t1 GROUP BY t1.B)
+val q6 = (SELECT COUNT(t2.E) AS N FROM t2 GROUP BY t2.D)
-
-datatype list a = Nil | Cons of a * list a
-
-val r1 : transaction (list string) =
- query q4
- (fn fs acc => return (Cons (fs.X, acc)))
- Nil
-
-val main : unit -> transaction page = fn () =>
- n <- r1;
- return <html><body>Nothing to see here!</body></html>
+fun main () : transaction page =
+ xml <- queryX q6 (fn r => <xml>{[r.N]};</xml>);
+ return <xml><body>{xml}</body></xml>
diff --git a/tests/agg.urp b/tests/agg.urp
new file mode 100644
index 00000000..61e6764e
--- /dev/null
+++ b/tests/agg.urp
@@ -0,0 +1,4 @@
+database /tmp/test
+sql agg.sql
+
+agg