root/trunk/projects/bos/queries.lisp

Revision 4338, 0.8 KB (checked in by hans, 18 months ago)

explain in sql

Line 
1;; ad-hoc queries that were useful
2
3;; contracts processed by gitte
4
5;; almost like
6;; select year, sum(contract-price) from contract where contract-paidp like "gitte" group by year(contract-date)
7
8(loop for year from 2007 upto 2009
9   do (format t "~A: ~A~%"
10              year
11              (reduce #'+
12                      (remove-if-not
13                       (lambda (contract)
14                         (and (= year (nth-value 5 (decode-universal-time (contract-date contract))))
15                              (cl-ppcre:scan "gitte" (if (stringp (contract-paidp contract))
16                                                         (contract-paidp contract)
17                                                         ""))))
18                       (class-instances 'contract))
19                      :key #'contract-price)))
Note: See TracBrowser for help on using the browser.