Hi I'm to stupid to write sql but im trying my hand at it anyways.
I cant work this out any easier than doing a seperate command but when i do that it takes forever. So i tried doing it as a subquery, but i think somehow i need to make it loop through my result set and do something special, but im not sure how to do it.
After i run this:

select aditm, adfvtr/10000 as price, ADAST,  (select max(adfvtr)/10000
from f4072
where adast = '510LIS' and 108284 < adexdj and 108284 > adeftj and admnq = 1  and aditm = '15'
group by aditm) as listprice
from f4072
where adast like '510%' and aditm  = '15'

I get this:

ADITM PRICE ADAST LISTPRICE
15 172.9 510LIS 198.835
15 198.835 510LIS 198.835
15 172.9 510RES 198.835
15 198.835 510RES 198.835

Which is correct, but what i want is that same code to apply to all of the records in ADITM

For example if aditm = 16 then i would want the rest of that subquery to be based around aditm = 16

If this makes no sense, please disregard and forget you ever read it

not sure what you are calling the code from, but you could either use a stored procedure with aditm passed in or create a view and filter the results based upon aditm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.