Force SQL result fields to integer? 
Author Message
 Force SQL result fields to integer?
Using P9.

In a SQL statement:

SELECT ClientID, count(access) as NumAccesses
FROM Patient
GROUP BY ClientID
ORDER BY ClientID

Is there any way to force the answer table's NumAccesses field to be a
certain data type - I'd prefer Integer?

TIA,

Karl Perry



Mon, 19 Dec 2005 22:23:27 GMT
 Force SQL result fields to integer?

Quote:

> Is there any way to force the answer table's NumAccesses field to be a
> certain data type - I'd prefer Integer?

The COUNT() function should already be returning an Integer.  If you want
to force a result to another data type, you can do this by using the
CAST() function.  Check it out in LocalSQL.hlp.

--
Larry DiGiovanni
Digico, Inc
IT Consulting and Staffing Solutions
www.digicoinc.com
Check out www.thedbcommunity.com for Paradox resources



Mon, 19 Dec 2005 22:27:46 GMT
 Force SQL result fields to integer?


Quote:

> > Is there any way to force the answer table's NumAccesses field to be a
> > certain data type - I'd prefer Integer?

> The COUNT() function should already be returning an Integer.  If you want
> to force a result to another data type, you can do this by using the
> CAST() function.  Check it out in LocalSQL.hlp.

Looks like I'll have to use CAST().  You're right, it should return an Int,
but it's returning an integer.

Karl



Tue, 20 Dec 2005 01:29:15 GMT
 Force SQL result fields to integer?

Quote:

> Looks like I'll have to use CAST().  You're right, it should
> return an Int, but it's returning an integer.

What are you looking at?  An Int and an integer are the same thing, aren't
they?

When I do

SELECT state, count(*) as NumStates
  FROM customer
GROUP BY state

The Numstates column of the answer table is type I - Long integer.  Isn't
that what you want?

--
Larry DiGiovanni
Digico, Inc
IT Consulting and Staffing Solutions
www.digicoinc.com
Check out www.thedbcommunity.com for Paradox resources



Tue, 20 Dec 2005 01:49:16 GMT
 Force SQL result fields to integer?


Quote:

> > Looks like I'll have to use CAST().  You're right, it should
> > return an Int, but it's returning an integer.

> What are you looking at?  An Int and an integer are the same thing, aren't
> they?

Sorry - I mistyped.  I meant to type "numeric" above but typed "integer"
instead.

I queried the same table several times using different date criteria:

SELECT ClientID, count(access) AS JuneTots (MayTots, etc.) FROM MyTable
WHERE EntryDate >= "06/01/2003" AND EntryDate <= "06/30/2003"

Then I queried for May, then for April, etc.

Sometimes the resulting column in the answer table was an integer, other
times it was a numeric.

When I later tried to combine things back together, I had problems and ended
up having to manually restructure all of the columns to the same type.  It
was quite a hassle.

Karl



Wed, 21 Dec 2005 02:29:33 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. Integer VB Vrs Integer SQL Arrrgggggggg

2. How to make a "decimal"-field to an "integer"-field

3. How to Join char field to integer field ?

4. link master autoInc field to Detail Integer field

5. Automatic random (unique) integer field in SQL Server?

6. Format integer data type field in SQL 6.5

7. SELECT - SQL with Integer fields

8. type mismatch when writing null to sql server integer field

9. Calculating time in minutes (integer result)

10. Decimal result from Integer Division

11. MSSQL 6.5 task - how to force result

12. Oracle Integer/Delphi Integer probl....


 
Powered by phpBB® Forum Software