Lets say I have a table called ABC in a MS-Access Database.
There are several columns in this table but only two columns are of interest for this question – “Hugo_symbol” and “Start_position”. “Hugo_Symbol” has gene names and several lines can have the same Hugo_symbol – meaning this column has duplicate entries. “Start_position” has numbers – anything from 1000 to 100000000.
I want to build a query that returns lines from table ABC that
1) Have the same Hugo_Symbol AND
2) Start_position is within 20 of each other.
For eg., the query should return,
Hugo_Symbol Start_Position
TP53 987654
TP53 987660
TP53 987662
APOB 12345
APOB 12350
APOB 12359
because these lines have the same Hugo_Symbol and Start_Position is within 20 of each other.
Is such a query possible? If so, what would the SQL code be?
I don’t use Access, but this is how I’d approach it with ANSI SQL.
This will potentially return more data that you expect, and potentially a different format that you expect.
EDIT:
The answer above is highly influence with “Each Other”.
If you reform the requirements as “all records where another record exists with the same symbol and a position with 20 of it’s own position” you could get something like…
But Access2000 is more limitted that the databases I normally use. I don’t know what Access2000 can and can’t do.