Invalid operator for data type

Posted on 2006-03-24
Last Modified: 2008-03-03
SELECT     ID, CASE WHEN Gender = 1 THEN (170 * Creatine ^ (- 0.999)
                      * Age^ (- 0.176) * BUN^ (- 0.17) * Alb^ 0.318)
                       END AS GFR
FROM         SAH_Master.dbo.ftblHC_HCC

This produces the error: "Invalid operator for data type.  Operator equals boolean XOR, type equals real.

I'm not sure what this error means and whether I can handle this within the query or if I need to change the data type of the fields themselves in order to do these calculations.

Question by:pansophy
    LVL 142

    Accepted Solution

    SELECT     ID, CASE WHEN Gender = 1 THEN (170 * POWER( Creatine , - 0.999)
                          * POWER ( Age , - 0.176) * POWER ( BUN, - 0.17) * POWER ( Alb, 0.318)
                           END AS GFR
    FROM         SAH_Master.dbo.ftblHC_HCC
    LVL 2

    Expert Comment

    from BOL

    The ^ bitwise operator can be used only on columns of the integer data type category.

    i guess one of your fields is a real and will need converting?

    if not please post the definitaion of table ftblHC_HCC
    LVL 75

    Expert Comment

    by:Aneesh Retnakaran
    Only integer vales are permissible for bitwise operations

    for eg :
    SELECT 234^(10)

    SELECT 234^(10.0) --wont work

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
    Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now