mysql - Can I sub query this or not? -



mysql - Can I sub query this or not? -

i've been trying query/subquery work stats have failed, started 1 time again scratch. can results want it's still in 2 separate queries. have little no experience sub queries after reasearching, heart tells me should able in 1 query. info in 1 table need utilize 2 separate grouping in order right data. i'm hoping can help me head around or @ to the lowest degree point me in right direction... in advance

select month(bookadhistory)-1 monthnum, count(distinct bookidhistory) totalbooks, count(distinct case when bookddchistory = 300 bookidhistory end) breaches bookhistory bring together book on bookid = bookidhistory bookid = 44 grouping month (bookadhistory) order monthnum; select month(historycreated)-1 monthnum, count(distinct case when bookddchistory between 1 , 99 bookidhistory end) delays, count(distinct case when bookddchistory = 200 bookidhistory end) extns, count(distinct case when bookddchistory = 100 bookidhistory end) lateclose bookhistory bring together book on bookid = bookidhistory bookid = 44 grouping month (historycreated) order monthnum;

there may ways simplify this, using have , sticking them in subquery(s) like:

select * ( select month(bookadhistory)-1 monthnum, count(distinct bookidhistory) totalbooks, count(distinct case when bookddchistory = 300 bookidhistory end) breaches bookhistory bring together book on bookid = bookidhistory bookid = 44 grouping month (bookadhistory) order monthnum ) t1 inner bring together ( select month(historycreated)-1 monthnum, count(distinct case when bookddchistory between 1 , 99 bookidhistory end) delays, count(distinct case when bookddchistory = 200 bookidhistory end) extns, count(distinct case when bookddchistory = 100 bookidhistory end) lateclose bookhistory bring together book on bookid = bookidhistory bookid = 44 grouping month (historycreated) order monthnum; ) t2 on t1.monthnum = t2.monthnum

mysql

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -