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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:07:51+00:00 2026-05-29T20:07:51+00:00

I am having an issue with the filtering my table F0005 properly. I have

  • 0

I am having an issue with the filtering my table F0005 properly. I have tried this query many different ways. What I want to accomplish is having the F0005 filtered before I join it.

This is how I want it filtered and the results are perfect on just that table.

SELECT LTRIM(F0005.DRKY), F0005.DRDL01, F0005.DRRT, F0005.DRSY
    FROM
            SENCOM.F0005 F0005
            WHERE LTRIM(F0005.DRKY) != '' AND F0005.DRRT IN ('W1','08') AND F0005.DRSY NOT IN ('30','32','98')

Here is my whole query and my attempt at filtering the table before joining it.

SELECT
    FSALES2011.SXAN8,
    FSALES2011.SXCO   AS Company,
    FSALES2011.SXMCU  AS BuisinessUnit,
    FSALES2011.SXLITM AS ItemNumber,
    FSALES2011.SXSLSM AS SalesPersonCode,
    FSALES2011.SXDCTO AS OrderType,
    FSALES2011.SXSLD1 AS SoldTo,
    FSALES2011.SXADD1 AS Address,
    FSALES2011.SXRP01 AS Division,
    FSALES2011.SXRP02 AS Location,
    FSALES2011.SXCI13+FSALES2011.SXCI14+FSALES2011.SXCI15+FSALES2011.SXCI16+FSALES2011.SXCI17+
    FSALES2011.SXCI18+FSALES2011.SXCI19+FSALES2011.SXCI20+FSALES2011.SXCI21+FSALES2011.SXCI22+
    FSALES2011.SXCI23+FSALES2011.SXCI24 AS PurchasePrice,
    FSALES2011.SXAS13+FSALES2011.SXAS14+FSALES2011.SXAS15+FSALES2011.SXAS16+FSALES2011.SXAS17+
    FSALES2011.SXAS18+FSALES2011.SXAS19+FSALES2011.SXAS20+FSALES2011.SXAS21+FSALES2011.SXAS22+
    FSALES2011.SXAS23+FSALES2011.SXAS24 AS SalesPrice,
    F4801.WAAN8,
    F4801.WAWR01         AS WoType,
    DIGITS(F4801.WADOCO) AS F4801ItemNumber,
    F0101.ABAN8,
    F0101.ABAC15              AS F0101CustomerType,
    F0006.MCRP08              AS JobType,
    SUBSTR(F0006.MCMCU,6,7)   AS F0006BuisnessUnit,
    LTRIM(F0005Filtered.DRKY) AS UDC,
    F0005Filtered.DRDL01      AS Description,
    F0005Filtered.DRRT,
    F0005Filtered.DRSY
  FROM
    SENDTA.F0101 F0101
  JOIN
    JDEMOD.FSALES2011 FSALES2011
  ON
    FSALES2011.SXAN8 = F0101.ABAN8
  LEFT OUTER JOIN
    SENDTA.F0006 F0006
  ON
    FSALES2011.SXLITM = SUBSTR(F0006.MCMCU,6,7)
  LEFT OUTER JOIN
    SENDTA.F4801 F4801
  ON
    FSALES2011.SXLITM = DIGITS(F4801.WADOCO)
  LEFT OUTER JOIN
    (
        SELECT
            LTRIM(F0005.DRKY),
            F0005.DRDL01,
            F0005.DRRT,
            F0005.DRSY
            FROM
            SENCOM.F0005 F0005
        WHERE
            LTRIM(F0005.DRKY) != ''
        AND F0005.DRRT IN ('W1',
                           '08')
        AND F0005.DRSY NOT IN ('30',
                               '32',
                               '98')) F0005Filtered
  ON
    ABAC15 = F0005Filtered.DRKY

When I try this I get Column errors, SQL0205] Column DRKY not in table F0005FILTERED in *N.

Thanks for any help I am kind of new to this and running out of ideas!! 🙂

Huge Thanks to Everyone, my problem was the formatting of my nested select but also something totally different. I was joining on the wrong field, so there were no matches and thats why i was getting the NULLs! thanks again!!

Here is the final version. Id be open to some optimization suggestions. Otherwise glad its done!

    SELECT
    FSALES2011.SXAN8,
    FSALES2011.SXCO   AS Company,
    FSALES2011.SXMCU  AS BuisinessUnit,
    FSALES2011.SXLITM AS ItemNumber,
    FSALES2011.SXSLSM AS SalesPersonCode,
    FSALES2011.SXDCTO AS OrderType,
    FSALES2011.SXSLD1 AS SoldTo,
    FSALES2011.SXADD1 AS Address,
    FSALES2011.SXRP01 AS Division,
    FSALES2011.SXRP02 AS Location,
    FSALES2011.SXCI13+FSALES2011.SXCI14+FSALES2011.SXCI15+FSALES2011.SXCI16+FSALES2011.SXCI17+
    FSALES2011.SXCI18+FSALES2011.SXCI19+FSALES2011.SXCI20+FSALES2011.SXCI21+FSALES2011.SXCI22+
    FSALES2011.SXCI23+FSALES2011.SXCI24 AS PurchasePrice,
    FSALES2011.SXAS13+FSALES2011.SXAS14+FSALES2011.SXAS15+FSALES2011.SXAS16+FSALES2011.SXAS17+
    FSALES2011.SXAS18+FSALES2011.SXAS19+FSALES2011.SXAS20+FSALES2011.SXAS21+FSALES2011.SXAS22+
    FSALES2011.SXAS23+FSALES2011.SXAS24 AS SalesPrice,
    F4801.WAAN8,
    F4801.WAWR01         AS WoType,
    DIGITS(F4801.WADOCO) AS F4801ItemNumber,
    F0101.ABAN8,
    F0101.ABAC15            AS F0101CustomerType,
    F0006.MCRP08            AS JobType,
    SUBSTR(F0006.MCMCU,6,7) AS F0006BuisnessUnit,
    LTRIM(UDC.DRKY)         AS Code,
    --UDC.DRDL01              AS JobDescription,
    --UDC2.DRDL01             AS WODescription,
    COALESCE(UDC.DRDL01,UDC2.DRDL01) AS WorkPerformed,
    UDC3.DRDL01                      AS CustomerDescription
FROM
    SENDTA.F0101 F0101
JOIN
    JDEMOD.FSALES2011 FSALES2011
ON
    FSALES2011.SXAN8 = F0101.ABAN8
LEFT OUTER JOIN
    SENDTA.F0006 F0006
ON
    FSALES2011.SXLITM = SUBSTR(F0006.MCMCU,6,7)
LEFT OUTER JOIN
    SENDTA.F4801 F4801
ON
    FSALES2011.SXLITM = DIGITS(F4801.WADOCO)
LEFT OUTER JOIN
    SENCOM.F0005 UDC
ON
    F0006.MCRP08 = LTRIM(UDC.DRKY)
AND LTRIM(UDC.DRKY) != ''
AND UDC.DRRT IN ('W1',
                 '08')
AND UDC.DRSY NOT IN ('30',
                     '32',
                     '98')
LEFT OUTER JOIN
    SENCOM.F0005 UDC2
ON
    F4801.WAWR01 = LTRIM(UDC2.DRKY)
AND LTRIM(UDC2.DRKY) != ''
AND UDC2.DRRT IN ('W1',
                  '08')
AND UDC2.DRSY NOT IN ('30',
                      '32',
                      '98')
LEFT OUTER JOIN
    SENCOM.F0005 UDC3
ON
    F0101.ABAC15 = LTRIM(UDC3.DRKY)
AND LTRIM(UDC3.DRKY) != ''
AND UDC3.DRRT IN ('15')
  • 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-29T20:07:52+00:00Added an answer on May 29, 2026 at 8:07 pm

    If you wrap a field in a function, you need to name it afterwards.

    Change LTRIM(F0005.DRKY), to LTRIM(F0005.DRKY) AS DRKY,

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

Sidebar

Related Questions

Hi guys I am having issue I have this query: SELECT * FROM useraccount
Having an issue here that I have tried everything I can think of but
Just started mongo and started having issue with querying already. i have a collection
G'day guys, I'm having an issue with filtering the presentation of several thousand trade
I'm having an issue with my linq query. I am trying to filter objects
Having issue with prefetching data and displaying on uitableview. So basically I want to
We have a device that support SAE J1939 interface and having issue with finding
I'm having an issue I've been fighting for a few hours, and have not
having issue with the explode, i have simple text file and each line is
I'm currently having issue going through a test backup and restore of database table

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.