Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

psql query problem with varchar and integer

Posted on 2001-08-23
7
927 Views
Last Modified: 2008-03-10
hi,

is it possible to convert a varchar to an integer with a query? something like "select * from table where INT(field) > 90"?

field is of type varchar

thanks for any help
0
Comment
Question by:brutebass
7 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6416575
Try this:

select * from table
where TO_NUMBER(field) > 90

Cheers
0
 

Author Comment

by:brutebass
ID: 6416592
i'm using postgresql v6.5 btw
0
 

Author Comment

by:brutebass
ID: 6416599
to_number doesnt work
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 1

Expert Comment

by:kdg2000
ID: 6416665
In MS SQL
select * from table where convert(int,field) > 90
0
 
LVL 2

Expert Comment

by:rajeXsh
ID: 6419605
There is a TO_NUMBER function in PostgreSQL
Here is a link to the documentaion
http://postgresql.cokernet.com/devel-corner/docs/postgres/functions-formatting.html
0
 
LVL 32

Accepted Solution

by:
bhess1 earned 50 total points
ID: 6420518
Although it isn't clear, it appears that PostgreSQL supports the CAST function.  Thus, try:

SELECT * FROM Table WHERE Cast(Field as Int) > 90

There is also a Cast character combination - two colons (::) that should be usable:

SELECT * FROM Table WHERE Field::Int > 90
0
 

Author Comment

by:brutebass
ID: 6420932
thanks, both solutions you posted work.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question