Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6698383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:34:17+00:00 2026-05-26T06:34:17+00:00

While using the following query, I get the error #1054 – Unknown column ‘plus’

  • 0

While using the following query,
I get the error

#1054 - Unknown column 'plus' in 'field list'

when plus-minus is used. Otherwise, query runs fine. I guess there is something related to Aliases which I do not know how to use. Please guide!

Thanks.

Query:

SELECT users.name,
count(*) as total, 
SUM(sms.views)+ SUM(sms.downloads)+ (SELECT count(*) FROM `smsfb` WHERE (`feedback`=1 OR `feedback`=100) AND userid=users.uniqueID) AS plus,
SUM(sms.delreq)+(SELECT count(*) FROM `smsfb` WHERE (`feedback`=5 OR `feedback`=6) AND userid=users.uniqueID) AS minus,
plus-minus
FROM sms,users
WHERE sms.deviceID=users.uniqueID AND sms.catid!=23 AND sms.catid!=44 AND sms.catid!=45
AND date>="2011-10-03" AND date<"2011-10-09" 
GROUP BY users.uniqueID HAVING total>10 ORDER BY total DESC LIMIT 0, 10
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:34:18+00:00Added an answer on May 26, 2026 at 6:34 am

    You can’t use the alias of a column inside the select part of the query.

    You could do it in this way:

    SELECT name
         , total
         , plus
         , minus
         , plus - minus
     FROM (
        SELECT users.name,
        count(*) as total, 
        SUM(sms.views)+ SUM(sms.downloads)+ (SELECT count(*) FROM `smsfb` WHERE     (`feedback`=1 OR     `feedback`=100) AND userid=users.uniqueID) AS plus,
        SUM(sms.delreq)+(SELECT count(*) FROM `smsfb` WHERE (`feedback`=5 OR `feedback`=6)     AND     userid=users.uniqueID) AS minus
        FROM sms,users
        WHERE sms.deviceID=users.uniqueID
          AND sms.catid!=23 AND sms.catid!=44
          AND sms.catid!=45
          AND date>="2011-10-03" AND date<"2011-10-09" 
        GROUP BY users.uniqueID HAVING total>10 ORDER BY total DESC
        LIMIT 0, 10
     ) plusAndMinus
    

    From Problems with Column Aliases:

    You can use the alias in GROUP BY, ORDER BY, or HAVING clauses to refer to the column

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using GWT I get following warning: Referencing deprecated class 'com.google.gwt.user.client.rpc.SerializableException' While it's only
while using the following constructor $this->pdo = new PDO ($this->source, $this->username, $this->password); if I
I experience the following problem while using legacy VC6. I just cann't switch to
I am using the following query to fetch a row with a particular mid
I am trying to build a cfquery using a dynamic column name: <cfquery dbtype=query
I am using ADOQuery in Delphi 7 and Oracle. I am getting error while
For pop up im using the following code style : a.selected { background-color:#1F75CC; color:white;
While using Struts2, I am using several annotations to do my validations inside the
While using Vim (at home and at work), I often find myself doing similar
While using regex to help solve a problem in the Python Challenge , I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.