Need help with "order by", "group by"
-
I need help constructing a query for my database application. Please use notepad to view the text file below for the problem's description. Thanks. http://www.nghiep.com/sqlhelp.txt[^]
Just a small modification (in bold) to your second query:
Select e.Event_ID, e.Event_Date, p.Prod_Name from EVENT e, PRODUCT p, EVENTS_PRODUCTS eps where e.Event_ID = eps.Event_ID and eps.Prod_ID = p.Prod_ID order by **e.Event_ID** p.Prod_Name DESC, e.Event_Date DESC
Then the grouping of data can be done in the code that renders the HTML. (Iterate through the results, and create a "group-seperator" only when Event_ID changes...) -
Just a small modification (in bold) to your second query:
Select e.Event_ID, e.Event_Date, p.Prod_Name from EVENT e, PRODUCT p, EVENTS_PRODUCTS eps where e.Event_ID = eps.Event_ID and eps.Prod_ID = p.Prod_ID order by **e.Event_ID** p.Prod_Name DESC, e.Event_Date DESC
Then the grouping of data can be done in the code that renders the HTML. (Iterate through the results, and create a "group-seperator" only when Event_ID changes...) -
Thanks for trying help...but I think your example would only sort the Prod_Names WITHIN each Event_ID group. But still, at the highest level, the table is sorted by Event_ID, not Prod_Name. I do not want that. I need the table to be sort by Product names.
Ah... So I need to actually READ your text...:-O Sorry, my fault...