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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:24:19+00:00 2026-06-17T09:24:19+00:00

I have 2 tables named tabItem and tabBin. Now data is fetched in a

  • 0

I have 2 tables named tabItem and tabBin. Now data is fetched in a Pivot table format via the code as mentioned below. Now the code below works as per expectations, but I am unable to add a column and a row total field.

Now the Row total is not based on all the cells in the rows, instead I am looking to sum only the following cells in a row, column headers are 1D + 2B + BRG + BHT, I am unable to find a way of doing this, we need to name this column “Total”.

Also I need to add another column which would print the following:

  1. If 1D + 2B < SO then “1 CORD”
  2. If Total < SO + ROL then “2 CSTK”

Similarly there are many other conditions something like 10~15 conditions, I am just not aware as to how to write the code since all the code mentioned has been written by searching on google but now I am unable to find answers and I am not at all versed with mysql. Any help would be highly appreciated.

select 
 `tabItem`.name as "Item Code:Link/Item:150",
 `tabItem`.description as "Description::300",
 ifnull(`tabItem`.re_order_level,0) as "ROL:Currency:50",
 ifnull(`tabBin`.reserved_qty,0) as "SO:Currency:50",
 ifnull(`tabBin`.ordered_qty,0) as "PO:Currency:50",
 ifnull(min(case when `tabBin`.warehouse="DEL20A" then `tabBin`.actual_qty end),0) as "1D:Currency:50",  
 ifnull(min(case when `tabBin`.warehouse="BGH655" then `tabBin`.actual_qty end),0) as "2B:Currency:50",    
 ifnull(min(case when `tabBin`.warehouse="RG-BGH655" then `tabBin`.actual_qty end),0) as "BRG:Currency:50",    
 ifnull(min(case when `tabBin`.warehouse="HT-BGH655" then `tabBin`.actual_qty end),0) as "BHT:Currency:50",    
 ifnull(min(case when `tabBin`.warehouse="FG-BGH655" then `tabBin`.actual_qty end),0) as "BFG:Currency:50",    
 ifnull(min(case when `tabBin`.warehouse="SLIT-DEL20A" then `tabBin`.actual_qty end),0) as "DSL:Currency:50",    
 ifnull(min(case when `tabBin`.warehouse="RG-DEL20A" then `tabBin`.actual_qty end),0) as "DRG:Currency:50",    
 ifnull(min(case when `tabBin`.warehouse="FG-DEL20A" then `tabBin`.actual_qty end),0) as "DFG:Currency:50", 
 ifnull(min(case when `tabBin`.warehouse="TEST-DEL20A" then `tabBin`.actual_qty end),0) as "DTS:Currency:50",    
 ifnull(min(case when `tabBin`.warehouse="REJ-DEL20A" then `tabBin`.actual_qty end),0) as "DRJ:Currency:50",   
 ifnull(min(case when `tabBin`.warehouse="RM-DEL20A" then `tabBin`.actual_qty end),0) as "DRM:Currency:50",    
 ifnull(min(case when `tabBin`.warehouse="RM-BGH655" then `tabBin`.actual_qty end),0) as "BRM:Currency:50"  
 from
 `tabItem`
 left join `tabBin` on
 `tabItem`.name = `tabBin`.item_code
where
 `tabBin`.item_code <>""
 and `tabBin`.item_code = `tabItem`.name    
group by `tabItem`.name
order by `tabItem`.name asc
  • 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-06-17T09:24:20+00:00Added an answer on June 17, 2026 at 9:24 am

    Try doing this with a subquery. Using your query . . .

    select t.*,
           ("1D:Currency:50" + "2B:Currency:50" + "BRG:Currency:50" + "BHT:Currency:50"
           ) as tot1,
           (case when "1D:Currency:50" + "2B:Currency:50" < "SO:Currency:50"
                 then '1 CORD'
                 when ("1D:Currency:50" + "2B:Currency:50" + "BRG:Currency:50" + "BHT:Currency:50" < "SO:Currency:50" + "ROL:Currency:50"
                 then  "2 CSTK"
             end)
    from (<your query>) t
    

    This should give you an idea of how to proceed.

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

Sidebar

Related Questions

I have 4 tables named wheels , tires , oil_change , other_servicing . Now,
So I have two tables. Table 1 is named 'appointment' with the following fields:
I have 2 tables, let says the first table named Schedule and the second
I have many tables, say T1, T2, T3. Every table has a column named
I have two MySQL tables named 'nodes' and 'joinTable' like shown below. I need
I have on table named players , then other tables named tries , conversions
I have tables named Events and Log. The Events table comprises of ID, Event
I have two tables named User, Holiday. Now my objective is to search user.
I have 2 tables: table 1 named table_1 table 2 named table_2 in the
Let's say you have a database with two tables named clients and referrals. 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.