Monday 15 February 2010

sql - MySQL SELECT and GROUPING -


I'm new to mySQL and I'm trying to create a query that is a special Google chart See results like: '' group_name '', 'open_tatescount', 'band_tatescount'], ['team a', 10, 400], [team b ', 30, 460], [' team C ', 66, 1120], [' Team D ', 5, 540]

I have a ticket table that includes the following fields: id ticket_status group_name Some things:

  1. In this example I have There are only two conditions, but the number of conditions is actually variable
  2. The number of teams also variable
  3. The actual group_name and ticket_statuses are the IDs for other tables in my actual table. How can I find the option)

    I have tried my imagination of everything and limited knowledge allows it and not even got close to receiving it. [Sample table structures (adding relevant areas only)]

      Table: ticket 'id', 'int (10)' 'ticket_stats_id', 'int (10) 'Ticket_graph_id', 'int (10)' table: status 'id', 'int (10)' 'name', 'wakr (250)' table: group 'id', 'int (10)' 'name' , 'Varchar (250)' '   

    > > SUM () and dynamic SQL ( PREPARE , EXECUTE ).

    Your original script may look like this

      SET @sql = ''; Select GROUP_CONCAT (different CONCAT ('SUM (case when t.ticket_status =' '', 'ID' 'then 1 ELSE 0 END ``, name, ``')) in position @ sql; SET @sql = CONCAT ('SELECT g.name', @sql, 'T.T.T.T.T..T.Ts on GON status from ticket TTT_Graw_ID on SIT GOT Group G = T.T.T.T.T.GOOG_ID by G.I.D., G.name '); Prepare SSML with SSMT; EXTUTE STMT; DEALLOCATE STMT;   

    Here is the demo.

No comments:

Post a Comment