SELECT query, COUNT(*) AS count FROM "search.log" USING LogExtractor GROUP BY query HAVING count > 1000 ORDER BY count DESC; OUTPUT TO "qcount.result";
也可以使用声明式语法:
1 2 3 4 5 6 7 8 9 10 11 12 13
e = EXTRACT query FROM “search.log" USING LogExtractor; s1 = SELECT query, COUNT(*) as count FROM e GROUP BY query; s2 = SELECT query, count FROM s1 WHERE count > 1000; s3 = SELECT query, count FROM s2 ORDER BY count DESC; OUTPUT s3 TO “qcount.result";
SELECT Ra, Rb FROM R WHERE Rb < 100 AND (Ra > 5 OR EXISTS(SELECT * FROM S WHERE Sa < 20 AND Sc = Rc))
可以改写为:
1 2 3 4 5 6
SQ = SELECT DISTINCT Sc FROM S WHERE Sa < 20; M1 = SELECT Ra, Rb, Rc FROM R WHERE Rb < 100; M2 = SELECT Ra, Rb, Rc, Sc FROM M1 LEFT OUTER JOIN SQ ON Rc == Sc; Q = SELECT Ra, Rb FROM M2 WHERE Ra > 5 OR Rc != Sc;
SCOPE脚本中还可以直接调用C#表达式,如:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
R1 = SELECT A+C AS ac, B.Trim() AS B1 FROM R WHERE StringOccurs(C, “xyz”) > 2
#CS public static int StringOccurs(string str, string ptrn) { int cnt=0; int pos=-1; while (pos+1 < str.Length) { pos = str.IndexOf(ptrn, pos+1) ; if (pos < 0) break; cnt++; } return cnt; } #ENDCS