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

  • SEARCH
  • Home
  • 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 1107617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:57:48+00:00 2026-05-17T01:57:48+00:00

The exact error I am getting is: Unknown column ‘trans_paid’ in ‘where clause’ My

  • 0

The exact error I am getting is: “Unknown column ‘trans_paid’ in ‘where clause'”

My query ($from_date and $to_date are correctly formatted):

SELECT 
   o.order_id,
   o.order_po_no,
   o.order_ship_date,
   acct.acct_company,
   SUM( ROUND( i.item_qty * i.item_price, 2 ) ) AS item_amount, (
      SELECT SUM( trans_amount )
        FROM transactions
      WHERE order_id = o.order_id
        AND trans_pending =0
        AND trans_date >= '$from_date'
        AND trans_date <= '$to_date'
   ) AS trans_paid
 FROM orders AS o
     INNER JOIN accounts AS acct ON o.acct_id = acct.acct_id
     INNER JOIN items AS i ON o.order_id = i.order_id
   WHERE (o.order_status =7 or o.order_status = 4)
      AND trans_paid IS NOT NULL
      AND acct.is_wholesale =1
      AND acct.acct_company LIKE '%".$_POST['company']."%'
 GROUP BY o.order_id
  • 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-17T01:57:48+00:00Added an answer on May 17, 2026 at 1:57 am

    Standard SQL doesn’t allow you to refer to aggregate columns in the WHERE clause. You need to move the trans_paid condition to a HAVING clause to make it work.

    Change

    WHERE (o.order_status =7 or o.order_status = 4)
        AND trans_paid IS NOT NULL
        AND acct.is_wholesale =1
        AND acct.acct_company LIKE '%".$_POST['company']."%'
    GROUP BY o.order_id
    

    to

    WHERE (o.order_status =7 or o.order_status = 4)
        AND acct.is_wholesale =1
        AND acct.acct_company LIKE '%".$_POST['company']."%'
    GROUP BY o.order_id
    HAVING trans_paid IS NOT NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting a bunch of failing tests (21 to be exact)/ an error message
The exact error I am getting is First-chance exception at 0x0096234a in chp2.exe: 0xC0000005:
The exact error I'm getting is: Cannot dynamic_cast 'object' (of type 'void*') to type
The exact error message I am getting through oXygen editor is The content of
We're getting this error java.lang.NullPointerException at java.util.ArrayList.<init>(Unknown Source) at de.mystuff.ExtendedArrayList.<init>(ExtendedArrayList.java:38) where ExtendedArrayList:38 is new
The exact error is as follows Could not load file or assembly 'Microsoft.SqlServer.Replication, Version=9.0.242.0,
This is aquamacs 1.5 on a macbook. Exact error when I try to spell-check:
The applicable code is below, as is the exact error. sd = socket(AF_INET, SOCK_RAW,
Exact Duplicate of: Getting the size (free,total) of a Windows Mobile phone drive using
This is my code and im getting an unreachable statement error on it but

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.