Results 1 to 3 of 3

Thread: Distinct Problem

  1. #1
    Join Date
    Dec 2002
    Posts
    3

    Distinct Problem

    Here's my problem.. I have a long list of schools, they have seperate cities and teachers. I want to list all of the schools that are participating, with their cities and a link to the contact for each. Now.. I only want each school to show up once.


    Here's a sample of my data:

    School Name / City / Teacher
    --------------------------------
    Oregon School / Portland / Susy
    Portland School / Portland / May
    Oregon School / Portland / Flu
    Portland School / Portland / Jess
    Willamette School / Willamette / Amy
    Oregon School / Portland / Maria
    Condon School / Condon / Dan
    Eugene School / Eugene / Moofy

    I want each school to show up just once I don't care which one it grabs, just needs to show up just once.

    So we should get a list that looks like this in alphabetical order:

    Condon School / Condon / Dan
    Eugene School / Eugene / Moofy
    Oregon School / Portland / Susy
    Portland School / Portland / Jess
    Willamette School / Willamette / Amy

    Each / seperated a column of data. I need to get a teacher for each, but I don't care which record it pulls up for each school the point is to have each school and city listed and when the user clicks on the school it's going to use that teachers name to display contact information I have everything working but the Select statement because I can not group because of the dumb Teacher Name.. can't be distinct because all of the other data is different... any thoughts?

    ~ Amber

  2. #2
    Join Date
    Mar 2003
    Location
    NJ
    Posts
    201
    select [school name],min(city),min(teacher) from list group by [school name]

  3. #3
    Join Date
    Jun 2003
    Location
    accra ghana
    Posts
    2

    Cool distinct

    if these are the columns of the table
    : School Name / City / Teacher

    to use the distinct syntax this is the sql

    select distinct(school name),city,teacher

    from students

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •