There is a table called 'NetworkSettings'
CREATE TABLE [dbo].[NetworkSettings](
[MpnMappingId] [bigint] IDENTITY(1,1) NOT NULL,
[PartNumber] [nvarchar](50) NULL,
[MPN] [nvarchar](50) NOT NULL,
[Network] [int] NOT NULL,
[Description] [nvarchar](500) NULL,
[System] [nvarchar](100) NULL,
[Damaged] [nvarchar](50) NULL,
PRIMARY KEY CLUSTERED
(
[MpnMappingId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
Now, if we execute below two quires:
SELECT Network FROM
(
SELECT
ROW_NUMBER() OVER (PARTITION BY MPN ORDER BY MPN) AS RowNum,
MpnMappingId, PartNumber, MPN, Network, [Description], [System], Damaged
FROM
NetworkSettings
) AS t
WHERE
t.RowNum = 1
and query below
SELECT * FROM
(
SELECT
ROW_NUMBER() OVER (PARTITION BY MPN ORDER BY MPN) AS RowNum,
MpnMappingId, PartNumber, MPN, Network, [Description], [System], Damaged
FROM
NetworkSettings
) AS t
WHERE
t.RowNum = 1
Both shows different results in Network column. but no of count are same.
Can any one tell reason for it? Also, in both case how SQL query runs and shows differnt results?