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 6728707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:12:08+00:00 2026-05-26T10:12:08+00:00

im trying to define the condition SR.PRODUCT_STOCK2 > 0 inside the sql code, since

  • 0

im trying to define the condition SR.PRODUCT_STOCK2 > 0 inside the sql code, since it AS of sum condition, here is the sql code

    SELECT P.PRODUCT_ID,P.PRODUCT_NAME,PS.MONEY,PR.PRICE,P.BRAND_ID,PS.PRICE,GSL.PRODUCT_STOCK,GSL.PURCHASE_ORDER_STOCK,GSL.SALEABLE_STOCK,P.PRODUCT_DETAIL2,P.BARCOD
<cfif isdefined('attributes.department_id') and len(attributes.department_id)>
    ,(SUM(SR.STOCK_IN)-SUM(SR.STOCK_OUT)) AS PRODUCT_STOCK2
</cfif>
FROM PRODUCT P
    JOIN PRICE_STANDART PS ON P.PRODUCT_ID = PS.PRODUCT_ID
    JOIN PRICE PR ON P.PRODUCT_ID = PR.PRODUCT_ID
    JOIN #DSN2_ALIAS#.GET_STOCK_LAST GSL ON P.PRODUCT_ID = GSL.PRODUCT_ID
    <cfif isdefined('attributes.department_id') and len(attributes.department_id)>
        JOIN #DSN2_ALIAS#.STOCKS_ROW SR ON P.PRODUCT_ID=SR.PRODUCT_ID
    </cfif>
WHERE PS.PURCHASESALES=1 AND PS.PRICESTANDART_STATUS=1 AND P.IS_SALES=1 AND P.IS_PURCHASE=1 AND P.IS_INTERNET=1 AND P.IS_EXTRANET=1
<cfif isdefined('attributes.department_id') and len(attributes.department_id)>
    AND
        (
        <cfloop list="#attributes.department_id#" delimiters="," index="dept_i">
        (SR.STORE = #listfirst(dept_i,'-')# AND SR.STORE_LOCATION = #listlast(dept_i,'-')#)
        <cfif dept_i neq listlast(attributes.department_id,',') and listlen(attributes.department_id,',') gte 1> OR</cfif>
        </cfloop>  
        )
        <cfif isdefined('attributes.is_stock') and attributes.is_stock is 1>
            AND SR.PRODUCT_STOCK2 > 0
        </cfif>
    </cfif>
GROUP BY P.PRODUCT_ID,PR.PRICE,P.PRODUCT_NAME,PS.MONEY,P.BRAND_ID,PS.PRICE,GSL.PRODUCT_STOCK,GSL.PURCHASE_ORDER_STOCK,GSL.SALEABLE_STOCK,P.PRODUCT_DETAIL2,P.BARCOD

the error log says: Invalid column name PRODUCT_STOCK2 i know that i wrongly defined the condition, i just don’t know how to define it right, need help! Thanks everyone for help!

  • 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-26T10:12:09+00:00Added an answer on May 26, 2026 at 10:12 am

    You are going to have to use a having clause like so:

    HAVING (SUM(SR.STOCK_IN)-SUM(SR.STOCK_OUT)) > 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write an MSBuild condition parser. The conditions are described here .
I'm trying to get the following SQL query to work in LINQ: Select id
Im trying to define a dataTemplate for a business object in my wpf application
I'm trying to define a task that emits (using echo) a message when a
I'm trying to define a table to store student grades for a online report
I am trying to define a WCF contract that returns an interface, something like
I'm trying to define a delegate function that will return an IEnumerable. I'm having
I'm trying to define a new shortcode in WordPress, and I get the following
I'm trying to define a way to simulate an case on accessing into a
I'm trying to define an action for a model Bar -- but I only

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.