move shared code
[sqlgg.git] / real.sql
blob6d31b32b92bd7b923386d42bff49ccd0c36da8d8
1  create table codeTable (locat INT, code TEXT, descript TEXT);
3  select * 
4  from codeTable
5  where locat not in (@lim1, @lim2)
6  and code not in
7    (
8     select code
9     from 
10       (select code, descript     // gets unique code-and-descript combos
11        from codeTable
12        where locat not in (@lim1, @lim2)
13        group by code, descript
14       )
15     group by code
16     having count(*) > @x     // (error? should be "="?)
17    )
18  order by code, locat;