kurbsdude Posted August 5, 2009 Share Posted August 5, 2009 so here's the problem I have a query as follows, SELECT *, COUNT(*) FROM (SELECT x WHERE num = 1 UNION ALL SELECT num1 WHERE id = 4) AS id GROUP BY id Is there a way to get MAX(COUNT(*)) without changing the "SELECT x WHERE num = 1 UNION ALL SELECT num1 WHERE id = 4" part? Thanks in advance, Cheers!! Quote Link to comment https://forums.phpfreaks.com/topic/168973-urgent-count-max-group-by/ Share on other sites More sharing options...
nadeemshafi9 Posted August 5, 2009 Share Posted August 5, 2009 you query is well messed up dude. do a count first select count(*) as myCount FROM tablename WHERE afeild = (select afeild from another_table_or_same where afeild = 1) this will return one row with mycount, you can group the counting proceedure group by feild that means it will only count the rows with feildname = thesame once then get the records after select * FROM tablename WHERE afeild = (select afeild from table where afeild = 1) i dont think you can get a count and the records all in one Quote Link to comment https://forums.phpfreaks.com/topic/168973-urgent-count-max-group-by/#findComment-891521 Share on other sites More sharing options...
kurbsdude Posted August 6, 2009 Author Share Posted August 6, 2009 this will return one row with mycount, you can group the counting proceedure group by feild that means it will only count the rows with feildname = thesame once absolutely, I get one row as mycount but group by merges the counts right? I just want to get one maximum value from one group (not merge all) thanks for the reply Quote Link to comment https://forums.phpfreaks.com/topic/168973-urgent-count-max-group-by/#findComment-891966 Share on other sites More sharing options...
nadeemshafi9 Posted August 6, 2009 Share Posted August 6, 2009 you dont need group by in that case SELECT count(*) FROM table WHERE group_type = 1 Quote Link to comment https://forums.phpfreaks.com/topic/168973-urgent-count-max-group-by/#findComment-892091 Share on other sites More sharing options...
roopurt18 Posted August 6, 2009 Share Posted August 6, 2009 If your problem is urgent, then you should post in the freelancing forum and pay money to have it resolved. Otherwise it's just as urgent as every other thread / problem. Quote Link to comment https://forums.phpfreaks.com/topic/168973-urgent-count-max-group-by/#findComment-892147 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.