D
Dave S.
Windows 2000, Access 97
I've got this table (import to Access as comma delimited):
session_id,question_id
s1,q1
s1,q2
s1,q3
s2,q1
s2,q3
s3,q1
....
I want a query that produces this:
session_id,question1,question2,question3
s1,q1,q2,q3
s2,q1,,q3
s3,q1,,
....
Note that some sessions_ids do not have all of the
question_ids that others do.
Querying the table against itself with LEFT JOINs followed
by WHERE constraints with a question_id does not work as
the WHERE is implemented after the join and no records
that are missing that particular question_id are shown.
SQL subqueries don't work either as Access only seems to
allow them in the WHERE clause with no alias.
I know I could create seperate queries for each question
and then LEFT JOIN them all. However, the real tables
have hundreds of question_ids and would therefore result
in a very large number of queries to deal with (enough to
make human error risk unacceptable).
I'd also prefer to avoid VBA as these some of these
queries will have to be put together or at least
understood by non-developers -- a simple, clever SQL
structure or a few formulas woud be ideal.
Anybody out there know a simple way to make Access only
look at a part of a table before it does an outer join?
Or have any other suggestions?
Thanks very much in advance, I really appreciate it.
I've got this table (import to Access as comma delimited):
session_id,question_id
s1,q1
s1,q2
s1,q3
s2,q1
s2,q3
s3,q1
....
I want a query that produces this:
session_id,question1,question2,question3
s1,q1,q2,q3
s2,q1,,q3
s3,q1,,
....
Note that some sessions_ids do not have all of the
question_ids that others do.
Querying the table against itself with LEFT JOINs followed
by WHERE constraints with a question_id does not work as
the WHERE is implemented after the join and no records
that are missing that particular question_id are shown.
SQL subqueries don't work either as Access only seems to
allow them in the WHERE clause with no alias.
I know I could create seperate queries for each question
and then LEFT JOIN them all. However, the real tables
have hundreds of question_ids and would therefore result
in a very large number of queries to deal with (enough to
make human error risk unacceptable).
I'd also prefer to avoid VBA as these some of these
queries will have to be put together or at least
understood by non-developers -- a simple, clever SQL
structure or a few formulas woud be ideal.
Anybody out there know a simple way to make Access only
look at a part of a table before it does an outer join?
Or have any other suggestions?
Thanks very much in advance, I really appreciate it.