You can get a kdb/q cookbook here:
http://code.kx.com/wiki/Cookbook
This includes a tutorial with a smartmeter concept which has several queries of increasing complexity:
http://code.kx.com/wsvn/code/cookbook_code/tutorial/
Step through this, look at the function definitions, cross-ref with the kdb reference page. Also read Q for mortals on their site:
http://code.kx.com/wiki/Tutorials
Yes it's not as accessible as other langs with loads of books, but on the plus side it's coherent, unlike c++.