in

System.Data.SQLite

An open source ADO.NET provider for the SQLite database engine

How to compare varchar() datatype with numeric value.

Last post 12-02-2008 10:22 AM by SqlRanger. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 11-26-2008 10:01 PM

    • Min
    • Top 500 Contributor
    • Joined on 07-02-2008
    • Nepal
    • Posts 4

    How to compare varchar() datatype with numeric value.

     Dear All,

    I have a column named amount1 varchar(50) in table tbTest. The column have value '0.00'

    My query is  Select * from tbTest WHERE IfNull(amount1, 0) > 0

    I expect this query should not return any rows but its returning.How to solve the problem.Is there any way to cast or conversion functions of data type. If any plz let me know or provide me the link. Thank you in advance.

    Filed under: , ,
  • 12-01-2008 3:41 AM In reply to

    Re: How to compare varchar() datatype with numeric value.

    WHERE CAST(amount1 AS REAL) > 0

    Regards

    Jesús López

  • 12-01-2008 4:32 AM In reply to

    • Min
    • Top 500 Contributor
    • Joined on 07-02-2008
    • Nepal
    • Posts 4

    Re: How to compare varchar() datatype with numeric value.

    Thank you very much Jesus Lopez. Now my query is working fine. Before you replyed me i used the query like Select * from tbTest WHERE ifNull(amount1,0) +  ifNull(amount1,0) > 0 which also gave me correct result. Once again thankyou very much. I tryed to search online but i could not find any example. Could you please provide me the link where i can see these functions and examples.

  • 12-02-2008 10:22 AM In reply to

    Re: How to compare varchar() datatype with numeric value.

    CAST is documented here: http://www.sqlite.org/lang_expr.html

    Core functions here: http://www.sqlite.org/lang_corefunc.html

    Date functions here: http://www.sqlite.org/lang_datefunc.html

    System.Data.SQLite also adds the following functions to the engine:

    acos, asin, atan, atn2, atan2, acosh, asinh, atanh, difference, degrees, radians, cos, sin, tan, cot, cosh, sinh, tanh, coth, exp, log, log10, power, sign, sqrt, square, ceil, floor, pi, replicate, charindex, leftstr, rightstr, reverse, proper, padl, padr, padc, strfilter, and aggregates stdev, variance, mode, median, lower_quartile, upper_quartile. 

     As documented in the readme file: http://sqlite.phxsoftware.com/readme.htm

     You can also add your own user defined functions. Here is an example: http://sqlite.phxsoftware.com/forums/p/1358/6156.aspx#6156

     

     

     

    Regards

    Jesús López

Page 1 of 1 (4 items)
Powered by Community Server (Commercial Edition), by Telligent Systems