I've got a sql question. If I have a table that has two columns, book and page, what is the best way to get a count of all the missing pages for each book?
So, if I have this table...
I want these results....
I've managed to do this, but my code is slow, cumbersome, and I'd be better off using a cursor. Anybody have an idea of how to do this fast and elegantly?
So, if I have this table...
Code:
Book Page
0001 0001
0001 0002
0001 0005
0001 0006
0002 0001
0002 0005
0002 0006
0002 0009
0003 0001
0003 0002
0003 0003
I want these results....
Code:
Book MissingPages
0001 2
0002 5
0003 0
I've managed to do this, but my code is slow, cumbersome, and I'd be better off using a cursor. Anybody have an idea of how to do this fast and elegantly?