0

I have a table in which i am trying to show the different years in which something was released. i have:

Name    Releasedate   Releasedate
Item 1  2001          2001
Item 1  2001          2001
Item 1  2001          2001

and the type of thing i want to end up with is:

Name    Releasedate   Releasedate
Item 1  2001          2002
Item 1  2001          2003
Item 1  2002          2003

This way it shows different release dates side by side without showing duplicates, or switching the order around ie. 2001-2002 -> 2002-2001

rags
  • 2,580
  • 19
  • 37
  • Do you always want them to be ordered such that the first column is the smaller value? – JustinDanielson Sep 13 '13 at 07:29
  • You have two columns with the same name? – Carter Sep 13 '13 at 07:30
  • I think he's joining a table on itself – JustinDanielson Sep 13 '13 at 07:31
  • yes, the first column should be of a smaller value. this is all done with the one table, but i havent got any joins made. i currently have only this: select Name, Releasedate, Releasedate from Table where Name in ( select Name from Table group by Name having (count(Name)>1)) – user2775426 Sep 13 '13 at 07:33
  • Would you be better off getting your data to return as [Item 1]|[2001]|[2002]|[2003], effectively presenting all of the release dates for an item on a single row? – rhollyer Sep 13 '13 at 07:59

2 Answers2

0

Assuming you have some table named tableName where the schema is Name, Releasedate

select a.Name, a.Releasedate, b.Releasedate 
from tableName a, tableName b
where a.Name = b.Name and a.Releasedate < b.Releasedate
JustinDanielson
  • 3,155
  • 1
  • 19
  • 26
0

If you means to find out duplicate values then this will help you. Check this one

OR try this one

Select 
    a.Name,a.releasedate, 
    b.Name,b.releasedate
From table a
    Join table b 
        On a.name = b.name 
            and a.releasedate < b.releasedate And a.rowid < b.rowid
Community
  • 1
  • 1
Ravi
  • 1,744
  • 2
  • 20
  • 37