|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Select whole numbers in decimal fieldI have a decimal field. Decimal (18,4)
How can I only select whole numbers from this field or vice versa? Thanks Not sure I understand the question fully, but here is a guess.
CREATE TABLE #Trash (t1 DECIMAL(18,4)) INSERT INTO #Trash (t1) values(1) INSERT INTO #Trash (t1) values(1.1) INSERT INTO #Trash (t1) values(2) INSERT INTO #Trash (t1) values(1.9999) INSERT INTO #Trash (t1) values(2.0001) SELECT t1 FROM #Trash WHERE CAST(t1 AS INTEGER) = t1 SELECT t1 FROM #Trash WHERE CAST(t1 AS INTEGER) <> t1 DROP TABLE #Trash Payson Terri wrote: Show quote > I have a decimal field. Decimal (18,4) > > How can I only select whole numbers from this field or vice versa? > > Thanks SELECT [number] FROM [Numbers]
WHERE FLOOR([number]) = [number] Should get you the whole numbers. -- Show quote"Terri" wrote: > I have a decimal field. Decimal (18,4) > > How can I only select whole numbers from this field or vice versa? > > Thanks > > > Thanks the FLOOR function is wahat I needed.
"Mark Williams" wrote Show quote > SELECT [number] FROM [Numbers] > WHERE FLOOR([number]) = [number] > > Should get you the whole numbers. > > -- > > > > "Terri" wrote: > > > I have a decimal field. Decimal (18,4) > > > > How can I only select whole numbers from this field or vice versa? > > > > Thanks > > > > > > Sorry to be so late with this. Does floor give you what you need with
negative numbers? Payson Terri wrote: Show quote > Thanks the FLOOR function is wahat I needed. > > "Mark Williams" wrote > > SELECT [number] FROM [Numbers] > > WHERE FLOOR([number]) = [number] > > > > Should get you the whole numbers. > > > > -- > > > > > > > > "Terri" wrote: > > > > > I have a decimal field. Decimal (18,4) > > > > > > How can I only select whole numbers from this field or vice versa? > > > > > > Thanks > > > > > > > > >
Other interesting topics
|
|||||||||||||||||||||||