another question with Coldfusion queries and group by

I had this question after viewing Getting data within a CFLOOP.

Hell again!! I wanted to try to expand on a functionality that I was helped with on here, and hopefully it will be a simple oversight on my part, but I wanted to get all of the records for one project and have those records placed in a textarea box, and that works great. But I also want to have a second textarea box that only shows the most recent comment per project number, and that textarea box will be modifiable, so a user can change the change inside that single comment on that textarea box. The code I have is below, but I can't seem to get the query right to get the single record for one textarea, while also getting all records for the other textarea.

<CFQUERY DATASOURCE="PDBARMYDEV" NAME="CecomInput">
 SELECT current_bulk_filter.proj_no,
current_bulk_filter.capces_location,
current_bulk_filter.capces_state,
current_bulk_filter.capces_description,
capces_support_history.proj_closed_reason

 FROM   mca.current_bulk_filter
   
left join mca.capces_support_history
on current_bulk_filter.proj_no = capces_support_history.proj_no  

where capces_support_history.proj_closed_reason is not null      
 order by current_bulk_filter.proj_no asc
</CFQUERY>



<cfoutput query="CecomInput" group="proj_no">
       <!--- This will print once for every project --->
       proj_no = #proj_no#<br>
       <!--- This will print each reason within a single textarea --->
     <textarea><cfoutput>#proj_closed_reason##chr(10)#</cfoutput></textarea>
     <br>
</cfoutput>
diecasthft01Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

_agx_Commented:
Just change the ORDER BY to also sort by a column in the history table so you get the newest reasons first.  I don't know the columns in your table, but say you had a "DateUpdated" column, sort by:

          ORDER BY current_bulk_filter.proj_no, capces_support_history.DateUpdated DESC

Then just add another textarea to the  outer cfoutput. That'll display the newest reason automatically.

<cfoutput query="CecomInput" group="proj_no">
       <!--- These values will only print once for every project --->
       proj_no = #proj_no#<br>
       <!--- Display first reason --->
      <textarea>#proj_closed_reason#</textarea>

       <!--- This will print each reason within a single textarea --->
     <textarea><cfoutput>#proj_closed_reason##chr(10)#</cfoutput></textarea>
     <br>
</cfoutput> 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
diecasthft01Author Commented:
Perfect!!! Thank you so much!!!
0
_agx_Commented:
Glad it helped!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.