Similarly, I have a long list of rows for each of the column mentioned above.
I have other EVENT too besides FIRST in my table, like SECOND, THIRD, FOURTH etc Therefore I would like to have my
SQL Query output as follows:
Datefield | FirstOccurances | Event | SecondOccurances | Event
July, 06 2013 00:00:00 4000 FIRST 4567 SECOND
Could anyone please help me in correcting my following query? I was thinking of using Sub queries but somehow it's not working:
SELECT (SELECT DATE(Timeduration) FROM MyDatabase) AS Datefield;
WHERE EVENT = "FIRST"
GROUP BY Timeduration) AS FIRSTOCCURANCES,
WHERE EVENT = "SECOND"
GROUP BY Timeduration) AS SECONDOCCURANCES;
Regarding query optimization, since I'm querying large database, what is the best way to run the queries fast? I tested the query using HeidiSQL but it takes lot of time to show the results on the screen over there itself.I do have Indexes created over there but it doesn't seem to be an efficient way I believe. Could anyone throw some light on this as well?