March 3, 2009 at 7:06 am
Dear all,
I am using the following simple query in order to get some columns in a table:
select TArticleTokens.Article,[TF-IDF]
from TArticleTokens order by TF-IDF desc
where TArticleTokens.Article is an int while TF-IDF is a float. However, even if I am ordering by float I am getting the following weird results:
36.8413614879047
27.6310211159286
16.094379124341
6.23832462503951
18.4206807439524
4.15888308335967
7.22383682595562
16.1180956509583
1.78337471969366
9.6566274746046
Is there something which I am missing?
Many thanks
March 3, 2009 at 9:12 am
Seems like you have something strange happening here.
I run the following code
create table floattest (id int identity(1,1), flval float)
insert into floattest
select flval from (Values (36.8413614879047), (16.094379124341), (6.23832462503951),
(27.6310211159286), (18.4206807439524), (4.15888308335967),
(7.22383682595562), (16.1180956509583), (1.78337471969366),
(9.6566274746046)) as f(flval)
select flval from floattest order by flval desc
And I get the following results
flval
----------------------
36.8413614879047
27.6310211159286
18.4206807439524
16.1180956509583
16.094379124341
9.6566274746046
7.22383682595562
6.23832462503951
4.15888308335967
1.78337471969366
Looks right to me. Perhaps you could give more information as to the structure of the table?
March 3, 2009 at 9:18 am
Many thanks for your reply,
The following the database script for the table.
USE [db1]
GO
/****** Object: Table [dbo].[TArticleTokens] Script Date: 03/03/2009 17:14:51 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[TArticleTokens](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Token] [int] NOT NULL,
[Article] [int] NOT NULL,
[TermCount] [int] NULL,
[TF] [float] NULL,
[DF] [float] NULL,
[IDF] [float] NULL,
[TF-IDF] [float] NULL,
[Language] [int] NULL,
[CollectionType] [int] NULL,
CONSTRAINT [PK_TArticleTokens] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
I believe that this is something that is happening server wide because I was getting the same thing with other tables. I have re-tried now and this time the values returned in the proper way. It does not seem to be happening all the time :S
Many thanks,
Chris
March 3, 2009 at 10:08 am
Hi all,
I managed to track down the error to a simple mistake in the syntax of the order by clause. I was ordering by TF-IDf, but both TF and IDF are also columns in that table, therefore the ordering was being done by the subtraction and not by the column values!
Many thanks for your help
Chris
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply