SJones
SJones

Reputation: 59

SQLite COUNT as type cast

I was wondering if it is possible to cast an integer gotten from a count to REAL

something like the following (though this doesn't work)

SELECT CAST (COUNT (ColumnA) AS Count) AS REAL) FROM Table1 WHERE ....

I can convert the Count INT to real externally from SQL but I would like to cut down on the steps I need to perform.

Upvotes: 1

Views: 590

Answers (1)

CL.
CL.

Reputation: 180060

A column alias must come after the entire expression:

SELECT CAST(COUNT(ColumnA) AS REAL) AS Count FROM ...

Upvotes: 1

Related Questions