sonal4php Posted July 19, 2006 Share Posted July 19, 2006 hi guysi am new to this forumand just need some help from u guysi am using "with rollup" in my mysql queryand it's running perfectwhat i want more is to display the 'total' fields in BOLD, which we get b'cuz of "with rollup" i have tried to pick up those particular entries using php languagebut no successi just wanna know, is there any thing, in the qry, which differentiates between normal rows o/p and total rows o/p as there r NULL entries for which we have applied GROUP BYi am using that NULL, but what abt the total count i get, i don't have any means to get the total count differently........plz helpi mean anything which i can use in my php codethanx in advancesonal Quote Link to comment https://forums.phpfreaks.com/topic/15016-mysql-with-rollup-functionality/ Share on other sites More sharing options...
shoz Posted July 19, 2006 Share Posted July 19, 2006 After fiddling around with a [b]basic[/b] ROLLUP query I was able to use MYSQL to differentiate between a grouped column with a NULL value and the rollup column with the NULL value using the following.[code]SELECTIF(group_col IS NULL, 'null_vals', group_col) AS group_col, SUM(val)FROMtableGROUP BY group_colWITH ROLLUP;[/code]eg output[code]group_col vala 10b 15null_vals 10NULL 35[/code]Note that the alias is required. Without it the rollup column is given one of the other columns values. I don't know why (The need for the alias etc) and because I don't quite understand the behaviour I can't recommend using this method.Perhaps it would be better to use PHP to do the ROLLUP. If you provide an example of the script and the query someone may be able to help. Quote Link to comment https://forums.phpfreaks.com/topic/15016-mysql-with-rollup-functionality/#findComment-60520 Share on other sites More sharing options...
fenway Posted July 19, 2006 Share Posted July 19, 2006 Yeah, ROLLUP is a little strange... I would recommend coding it in PHP instead, because you can make it much more flexible this way, and you don't have version compatability issues. Quote Link to comment https://forums.phpfreaks.com/topic/15016-mysql-with-rollup-functionality/#findComment-60526 Share on other sites More sharing options...
sonal4php Posted July 20, 2006 Author Share Posted July 20, 2006 thanx guys 4 helpeven i understand that php is much more flexible to deal with thisbut i have a very long list of records, alongwith different kind of listings at a timei mean it's something like 7 columns and around 1000 rowsand column needs to be summed up, total is displayed at around 15 timesso to associate each column and make special SUM() for all, is just so time consuming to executei thought, it would be much more simpler to use WITH ROLLUPso i turned to thiswell, and i am getting good results evenbut only prob is that, i want to display the total count fields in bold, so that user can differentiate it easilybut i guess, i shud do something with php itselfthanx once again 4 ur timegayatri Quote Link to comment https://forums.phpfreaks.com/topic/15016-mysql-with-rollup-functionality/#findComment-60827 Share on other sites More sharing options...
fenway Posted July 20, 2006 Share Posted July 20, 2006 You can do half & half... get individual SUMs, then "rollup" yourself. Quote Link to comment https://forums.phpfreaks.com/topic/15016-mysql-with-rollup-functionality/#findComment-61099 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.