|
|
|
start date: Mon, 13 Aug 2007 16:45:28 +0800,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
chenhong
|
|
2
Mark Rae [MVP]
|
|
3
Ladislav Mrnka
|
how to distinguish two row in sql server
a query return with some identical rows,
how can I distinguish them?
what I want is like this:
select rowid, column1, column2 from mytable
TIA
Date:Mon, 13 Aug 2007 16:45:28 +0800
Author:
|
Re: how to distinguish two row in sql server
"chenhong" wrote in message
news:eQYwbbY3HHA.3900@TK2MSFTNGP02.phx.gbl...
>a query return with some identical rows,
> how can I distinguish them?
>
> what I want is like this:
>
> select rowid, column1, column2 from mytable
>
> TIA
select DISTINCT rowid, column1, column2 from mytable
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Date:Mon, 13 Aug 2007 10:22:38 +0100
Author:
|
RE: how to distinguish two row in sql server
Hi,
if you would like to distinguish between two identical rows you have to
change your query to use some row numbering. SQL 2005 provides you mechanism
to do that:
select
NumberedTable.*
from
(
select
column1, column2,
ROW_NUMBER() over (order by column1, column2) as RowNum
from myTable
) NumberedTable
If you do not use SQL 2005 you have to create temporary table with one more
identity column and first fill this table with your date and after that
select that data from this table.
There is still question if your identical rows will always be in same order
but who knows? :)
Regards,
Ladislav
"chenhong" wrote:
> a query return with some identical rows,
> how can I distinguish them?
>
> what I want is like this:
>
> select rowid, column1, column2 from mytable
>
> TIA
>
Date:Mon, 13 Aug 2007 02:30:00 -0700
Author:
|
|
|