I have the following tables, users which is self explanatory and answers which contains a list of responses on a given date for a specific user.
users
-----
ID FIRST_NAME LAST_NAME
1 Joe Bloggs
2 Fred Sexy
3 Jo Fine
4 Yo Dude
5 Hi There
answers
-------
ID CREATED_AT RESPONSE USER_ID
1 2011-01-01 3 1
2 2011-01-01 4 2
3 2011-01-02 5 5
My aim is to build a view which would output the following:
USER_ID CREATED_AT RESPONSE
1 2011-01-01 3
2 2011-01-01 4
3 2011-01-01 NULL
4 2011-01-01 NULL
5 2011-01-01 NULL
1 2011-01-02 NULL
2 2011-01-02 NULL
3 2011-01-02 NULL
4 2011-01-02 NULL
5 2011-01-02 5
I have been trying to do this in one SELECT statement but I don't believe it is possible, maybe I'm missing something? I can accomplish the output with multiple statements but I'm looking for a more elegant method which can sit in a view (or multiple views).
Thanks in advance!