From: Rick James Date: September 13 2012 4:28pm Subject: RE: query help List-Archive: http://lists.mysql.com/mysql/228165 Message-Id: <2E7DD7ADE53B044C8C8BCD9C5829E1EB148B8899BB@SP2-EX07VS01.ds.corp.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Transposing is ugly in SQL. It is better done in some other language (PHP,= Java, ...) If you must do it in SQL, search for pivot Peter Brawley > -----Original Message----- > From: Stillman, Benjamin [mailto:BStillman@stripped] > Sent: Thursday, September 13, 2012 7:09 AM > To: 'Richard Reina'; mysql@stripped > Subject: RE: query help >=20 > I think this will get you there: >=20 > SELECT LEAD, COUNT(*) FROM ORDERS GROUP BY LEAD; >=20 > It'll give you something more like: >=20 > | LEAD | COUNT(*) | > | F | 44 | > | S | 122 | > | R | 32 | >=20 >=20 >=20 > -----Original Message----- > From: Richard Reina [mailto:gatorreina@stripped] > Sent: Thursday, September 13, 2012 9:51 AM > To: mysql@stripped > Subject: query help >=20 > I have a table like this: >=20 > |ORDERS| > |ID | DATE | QNT | LEAD | > |342 | 8-12-12 | 32 | F | > |345 | 8-15-12 | 12 | S | > |349 | 8-16-12 | 9 | R | >=20 > I am looking for a way to query it with counts by the LEAD column in > order to tell what the number of each type lead is, so that I get > something like this: >=20 > F_LEADS S_LEADS R_LEADS > 44 122 32 >=20 > Is this possible? If so can anyone help with syntax? >=20 > Thanks, >=20 > Richard >=20 > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/mysql >=20 >=20 > ________________________________ >=20 > Notice: This communication may contain privileged and/or confidential > information. If you are not the intended recipient, please notify the > sender by email, and immediately delete the message and any attachments > without copying or disclosing them. LBI may, for any reason, intercept, > access, use, and disclose any information that is communicated by or > through, or which is stored on, its networks, applications, services, > and devices. >=20 > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/mysql