edlanter Posted December 17, 2003 Share Posted December 17, 2003 Hi. Here is what I would like a querry to display .... State County Viginia Roanoke Salem Blacksburg Vermont Norwich Veronie In english, I would like to create a querry that only prints the State the first time it is selected followed by the county for each line the State is the same as the previous one. In the example, the state changed from Virginia to Vermont so it printed Vermont. (the example is supossed to be two columns) Something is telling me this is a Group By command, but I honestly can\'t remember so any feedback would be great. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/1520-group-by-i-think/ Share on other sites More sharing options...
Barand Posted December 17, 2003 Share Posted December 17, 2003 Nope, not a \'GROUP BY\' in this instance, that\'s for totals, averages etc. You need to \"select state, county from tablename order by state, county\" When you process the records, test for a change of \'state\' and only output the state value when not equal to the previous one. Always output the county value. hth Quote Link to comment https://forums.phpfreaks.com/topic/1520-group-by-i-think/#findComment-4995 Share on other sites More sharing options...
edlanter Posted December 17, 2003 Author Share Posted December 17, 2003 Thanks!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/1520-group-by-i-think/#findComment-4997 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.