Use SELECT C. Cntldate, C. Sd_class, C.
Created, R. Restored FROM ( SELECT DATE(crtdtime) AS cntldate, sd_class, COUNT(crtdtime) AS created FROM master GROUP BY cntldate, sd_class ) C INNER JOIN ( SELECT DATE(rstdtime) AS cntldate, sd_class, COUNT(rstdtime) AS restored FROM master GROUP BY cntldate, sd_class ) R ON R. Cntldate = C.
Cntldate AND R. Sd_class = C. Sd_class WHERE C.
Cntldate = '2011-11-16' AND R. Cntldate = '2011-11-16.
Thank you all for your help it was very much appreciated and went with Yahia's version as it gave me the most flexibility. – mybigman Nov 18 at 22:01 @mybigman you are welcome :-) please don't forget to upvote/mark as accepted any answer that was of help (see meta.stackoverflow. Com/questions/5234/…).
– Yahia Nov 18 at 22:05.
One possible way SELECT DATE(crtdtime) AS cntldate, sd_class, sum( DATE(crtdtime) = '2011-11-16') AS created sum( DATE(rstdtime) = '2011-11-16') AS restored FROM master WHERE DATE(crtdtime) = '2011-11-16' or DATE(rstdtime) = '2011-11-16' GROUP BY cntldate, sd_class.
I was just about there... this, however works if and only if a single date... – DRapp Nov 18 at 1:15.
How about select q1. Cntldate, q1. Sd_class, q1.
Created, q2. Restored from ( SELECT DATE(crtdtime) AS cntldate, sd_class, COUNT(crtdtime) AS created FROM master WHERE DATE(crtdtime) = '2011-11-16' GROUP BY cntldate, sd_class ) q1 inner join ( SELECT DATE(rstdtime) AS cntldate, sd_class, COUNT(rstdtime) AS restored FROM master WHERE DATE(rstdtime) = '2011-11-16' GROUP BY cntldate, sd_class ) q2 on q1. Cntldate=q2.
Cntldate and q1. Sdclass = q2. Sdclass This is Postgres syntax though, so might have to play with it to get it running with MySql.
It actually isn't that difficult (once you've been doing it a while). Use a SUM( IF() ) such as... SELECT date( if( date( ctrdtime ) = '2011-11-16', ctrdtime, rstdtime )) as CntlDate, sd_class, sum( if( date( ctrdtime ) = '2011-11-16', 1, 0 ) ) as CreatedCount, sum( if( date( rstdtime ) = '2011-11-16', 1, 0 ) ) as RestoredCount FROM master WHERE DATE(crtdtime) = '2011-11-16' OR DATE(rstdtime) = '2011-11-16' GROUP BY 1, 2 This would also work if you expanded a date range for both created and restored...
I believe this will work: SELECT DATE(m1. Crtdtime) AS cntldate, m1. Sd_class, COUNT(m1.
Crtdtime) AS created , ( SELECT COUNT(m2. Rstdtime) FROM master m2 WHERE DATE(m2. Rstdtime) = DATE(m1.
Rstdtime) and m2. Sd_class=m1. Sd_class ) as restored FROM master m1 WHERE DATE(crtdtime) = '2011-11-16' GROUP BY cntldate, sd_class.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.