Jump to content

Group By ... I Think


edlanter

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.