Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Distinct columns

Status
Not open for further replies.

bluebytez

Programmer
Dec 20, 2001
39
0
0
MY
Hi i have a table with columns a,b,c,d and i want to insert it into another table with the condition that a,b,c is not the same. If a and b and c is the same, then don't insert. Either one is different, then insert.
I can't use distinct because distinct can only be applied to one column.
Can anyone help me get around this problem ?


 
I thought distinct could be applied to more than one column. Although I think you want the distinct values of each columns rather than the distinct combination of column values? Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
Can i use distinct on more than one columns ?
How do i construct for this then ? I am looking for distinct combination of a,b,c. That means all three a,b,c CANNOT be the same.
For instance a = Name, b = Month, c = Year, d = whatever.
I want a resultset where name can be duplicated ONLY IF the month and year is different. If Name, Month and Year is the same, I would like to discard this row.
How do I write the query ?
select distinct(name,month,year), whatever from table1 ?
or
select distinct(name), distinct(month), distinct(year), whatever from table1 ?
either way, my query analyser will not parse the statements.
Please help !
 
Try...

select distinct name, month, year from blah Ladyhawk. [idea]
** ASP/VB/Java Programmer **
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top