Having trouble with basic sql query, I need to summarize a lot of information and the query i'm using is:
SELECT date, id, actions
FROM accounts
WHERE (date between '2013-07-01' and '2013-9-30') AND (id in (---ids---));
Right now I'm getting
date 1 id1 actions
date 2 id1 actions
date 3 id1 actions
date 4 id1 actions
date 5 id1 actions
date 6 id1 actions
date 1 id2 actions
date 2 id2 actions
date 3 id2 actions
date 4 id2 actions
date 5 id2 actions
date 6 id2 actions
what i want is
date 1 id1 actions id2 actions
date 2 id1 actions id2 actions
date 3 id1 actions id2 actions
date 4 id1 actions id2 actions
date 5 id1 actions id2 actions
date 6 id1 actions id2 actions
What's the easiest way of doing this?
id1toid2? Or, how isid1andid2related to the dates?PIVOTto put them into something similar but withid1andid2as the column names.