What is the CQL syntax for combinations where king is checked along a file, and the square near it is attacked by bishop or queen? I am looking to search for combinations similar to the one in Karpov - Taimanov, 1977 - a knight check, is followed by opening of an 'h' file, and the rook comes with decisive effect because attacker's queen covers the diagonal. I am only learning CQL and any tips on how to get started on constructing a query would be much appreciated - 

[Event "October Revolution 60th Anniversary"]
[Site "Leningrad URS"]
[Date "1977.06.25"]
[EventDate "1977.??.??"]
[Round "1"]
[Result "0-1"]
[White "Anatoly Karpov"]
[Black "Mark Taimanov"]
[ECO "B32"]
[WhiteElo "?"]
[BlackElo "?"]


[PlyCount "76"]

[FEN " "]
1. e4 c5 2. Nf3 Nc6 3. d4 cxd4 4. Nxd4 a6 5. c4 e5 6. Nb3 Nf6
7. Nc3 Bb4 8. f3 O-O 9. Be3 d6 10. Rc1 b6 11. Bd3 Bc5 12. Qd2
Be6 13. Nxc5 bxc5 14. O-O Nd4 15. Nd5 Nd7 16. f4 Rb8 17. f5
Bxd5 18. cxd5 Qb6 19. Rf2 f6 20. Rc4 a5 21. Ra4 Ra8 22. Qe1
Ra7 23. b3 Rfa8 24. Rb2 Qc7 25. Bd2 Nb6 26. Rxa5 c4 27. Bf1
Rxa5 28. Bxa5 Qc5 29. Bxb6 Qxb6 30. Kh1 cxb3 31. axb3 g6
32. fxg6 hxg6 33. b4 Kg7 34. b5 f5 35. exf5 Nxf5 36. Rb3 Qd4
37. b6 Ra1 38. Rb1 Ng3+ {analysis: 39. hxg3 Ra8} 0-1
I'm still working out the full answer, but this is a start:

flipcolor {wtm check ng3 Pg2 Ph2 Kh1 r attack (q g1) not {square $x in h3-8 a on $x} result 0-1}

This gets down to 13 games from over 2 million and includes the Karpov - Taimanov game. I still haven't figured out a way to deal with the rook, but
this gets a game list small enough to look through. The not square bits could be taken out to expand the search to a couple hundred games, that was just looking for the h file to not be blocked by black pieces for the later rook move.

I used the above in the latest scid vs pc codebase, which has cql support by adding cql() to the beginning and running it in the cql search vs what is Chessbase Big Database 2017 updated to last month.