How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask tejas_speed Your Own Question
tejas_speed
tejas_speed, Computer Software Engineer
Category: Programming
Satisfied Customers: 21
Experience:  Computer Engineer With Knowledge of ASP.Net and C#
32711602
Type Your Programming Question Here...
tejas_speed is online now
A new question is answered every 9 seconds

I need help doing a join on existing SQL code

Customer Question

I need help doing a join on existing SQL code
Submitted: 1 year ago.
Category: Programming
Expert:  Leela-TheProgrammer replied 1 year ago.

Hi,

Thanks for using JustAnswer.

This is Leela and I will help you with the question today.

Please provide more details about your question.

Regards,

Leela

Customer: replied 1 year ago.
I AM TRYING TO GET THIS COLUMN TO DISPLAY FROM THIS TABLE:Description from [200].dbo.itemassortment where items.assortment = itemassortment.assortmentHERE IS MY CURRENT QUERY THAT IS WORKING:select distinct kk.shiptoRSM, yy.* from (select distinct convert(varchar(6), frhkrg.fakdat, 112) as yyyymm,
(select sur_name from [200].dbo.humres where cmp_acc_man = res_id) as slsman,
cicmpy.debcode,
frhkrg.inv_debtor_name,
case when cicmpy.classificationid = 'AAK' then 'USER' else 'DIST' end as class,
frhkrg.faknr, frhkrg.ordernr,
--case when frhsrg.artcode is not null then 'MACH' ELSE 'PART' END AS partNo,
(select assortment from [200].dbo.items where frhsrg.artcode = items.itemcode and ((assortment between 100 and 330 ) or (assortment between 100000 and 499999 ))) as igroup,case when frhsrg.artcode is not null then frhsrg.artcode ELSE 'PART' END AS partNo,
frhsrg.oms45,
(frhkrg.tot_bdr_vv) as ntAmount,/*(select sum(bdr_ev_ed_val) from [200].dbo.frhsrg where ar_soort = 'P' and faknr = frhkrg.faknr) as xcost, */(select sum(bdr_ev_ed_val) from [200].dbo.frhsrg where (ar_soort = 'P' or artcode = 'ADEP') and faknr = frhkrg.faknr) as xcost,ord_statecode, del_statecode, price, frhsrg.esr_aantal qty
from
(select xx.faknr, regel, price from
(
select faknr, max(prijs83) price
from [200].dbo.frhsrg
where ar_soort in ('V','C','A','B') and (substring(artcode,1,1) not in ('*', '+', '-'))
--and faknr like '%(###) ###-####
group by faknr) xx
left join [200].dbo.frhsrg x1 on xx.faknr = x1.faknr and price = x1.prijs83) xf
left join [200].dbo.frhkrg on xf.faknr = frhkrg.faknr
LEFT OUTER JOIN [200].dbo.cicmpy ON frhkrg.fakdebnr = cicmpy.debnr and frhkrg.fakdebnr IS NOT NULL AND cicmpy.debnr IS NOT NULL
left join [200].dbo.frhsrg on frhsrg.faknr = xf.faknr and xf.regel = frhsrg.regel
WHERE frhkrg.fakdebnr IS NOT NULL AND frhkrg.fak_soort IN ('V','C','A','B')
and (substring(artcode,1,1) not in ('*', '+', '-')) and frhsrg.ar_soort 'P'
--##################################################################################################
and convert(varchar(6), frhkrg.fakdat, 112) like [email protected]+'%'
--and convert(varchar(6), frhkrg.fakdat, 112) <= 201302
and frhkrg.ordernr like [email protected]+'%'
--and (case when frhsrg.artcode is not null then 'MACH' ELSE 'PART' END ) = 'MACH'
--and frhkrg.faknr like '%2005942%'
--Group by convert(varchar(6), frhkrg.fakdat, 112), cmp_acc_man, cicmpy.debcode, frhkrg.inv_debtor_name, cicmpy.classificationid, frhkrg.faknr, frhkrg.fak_soort
--ORDER BY yyyymm, slsman, class, frhkrg.inv_debtor_name, faknr
) as yyleft join
(select faknr, hr.sur_name as shiptoRSM
from [200].dbo.frhkrg hd
left join [200].dbo.humres hr on hd.represent_id = hr.res_id
) as kk on kk.faknr = yy.faknrwhere yy.igroup is not nullORDER BY yy.yyyymm, yy.slsman, yy.class, yy.inv_debtor_name, yy.faknr--ORDER BY yyyymm, slsman, class, inv_debtor_name, faknr
Expert:  Leela-TheProgrammer replied 1 year ago.

Hi,

The information provided is not clear. Can you please provide the information in a proper way (as clear paragraphs) so that I understand the question better.

Thanks,

Leela

Customer: replied 1 year ago.
Can you please explain what is not clear. I have a query that is currently working and I want to show a column from another table (description from [200].dbo.itemassortment) where assortment from [200].dbo.itemassortment connects assortment from [200].dbo.items.
Expert:  Leela-TheProgrammer replied 1 year ago.

The content is all clubbed, the query is not clear, I guess it has some comments also, all got mixed up into few lines.

As the question is not clear I couldnt answer it. I am opting out so that other expert can help you.

All the best.

Thanks,

Leela

Expert:  tejas_speed replied 1 year ago.

I could see that there is commented code '--case when frhsrg.artcode ' . May I know how much part is commented or could you please remove the commented part and send the query again?

Related Programming Questions