acook Posted August 9, 2007 Share Posted August 9, 2007 Does anyone know if this is possible: I'm running a query against a db and am pulling name and ticket # (for a helpdesk)... What I'd like to do is take the results from the "Name" field, but only show EACH NAME ONCE in a table. For example, I might get 200 results back, but only want to show the name of the person once, with how many tickets they have assigned to them. So it would look like this: ___Name___|___Number of tickets___ ___Bob____|__________3__________ ___John____|_________23__________ ___Mark____|_________4___________ ...etc, etc... does anyone know how to go about starting this? I'm assuming an array of sorts. Any help would be appriciated! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/64099-avoiding-duplicate-results/ Share on other sites More sharing options...
trq Posted August 9, 2007 Share Posted August 9, 2007 SELECT Name, COUNT(Ticket) AS Number_of_tickets GROUP BY Name; Quote Link to comment https://forums.phpfreaks.com/topic/64099-avoiding-duplicate-results/#findComment-319434 Share on other sites More sharing options...
acook Posted August 9, 2007 Author Share Posted August 9, 2007 Hmm, I'm not sure I understad. This is my query now: $query = "SELECT Create_Date, Request_Type, Assignee_Group, Assignee_Individual, Status, Request_Task_ID FROM Request_Task WHERE (Status='Active' OR Status='Assigned' OR Status='Acknowledged' OR Status='Held' OR Status='Pending' OR Status='Pending Cancellation' OR Status='WIP') AND (Assignee_Group='Security')"; So I would want to isolate "Assignee_Individual" and I guess count how many of each type of ticket that person had. And the table would look like: ___NAME___|___Assigned___|___Acknowledged___|___Held___|___Pending___|___WIP___ Mark 5 6 11 3 5 Could that same query be rewritten the way you suggested? I guess I wasn't clear enough. It seems like some math would need to happen. Quote Link to comment https://forums.phpfreaks.com/topic/64099-avoiding-duplicate-results/#findComment-319545 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.