• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQL Select Help

 
Richard Murry
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hoping someone can help me out here . . .

I have a table that contains a number of records. It has two fields, "Starter" and "Main Course". Typical data would look like this. . .

Starter�Main
Soup, Beef
Soup, Chicken
Salad, Pork
Soup, Beef
Salad, Chicken
Soup, Beef
Salad, Pork
etc . . .

I need to try and select all similar pairs that occur in the table more than once. For example, in the above table, I would be looking to select Soup and Beef and Salad and Pork as they occur more than twice.

Anyone help?
 
Chad Clites
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Off the top of my head, something like:
SELECT Starter, Main, Count(Main)AS cnt FROM my_table WHERE cnt>1;
should get you a list of any duplicates.
[ August 29, 2007: Message edited by: Chad Clites ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic