this article on cross tabulations should help you ...

http://www.mysql.com/articles/wizard/index.html

- hcir

(mysql sql query)

On Friday, Mar 14, 2003, at 11:40 America/Anchorage, DANIEL GADDIS wrote:


I'm running MySql 4.0.10-gamma-max-nt-log


I have 1 table like the one below...

+------------+---------+--------------+
| DAY        | USERID  | LIS_QUANTITY |
+------------+---------+--------------+
| 2003-01-02 | H0850A1 |          539 |
| 2003-01-02 | LBBSWJR |            7 |
| 2003-01-02 | O0600B3 |           21 |
| 2003-01-03 | H0850A1 |            6 |
| 2003-01-03 | H2610A1 |           51 |
| 2003-01-03 | O0600B3 |           19 |
| 2003-01-04 | H0850A1 |            8 |
| 2003-01-04 | H2610A1 |           13 |
| 2003-01-04 | LBBSWJR |            3 |
+------------+---------+--------------+

I would like a sql query to produce output like the following...

+---------+------------+------------+------------+
| USERID  | 2003-01-02 | 2003-01-03 | 2003-01-04 |
+---------+------------+------------+------------+
| H0850A1 |        539 |          6 |          8 |
| H2610A1 |            |         51 |         13 |
| LBBSWJR |          7 |            |          3 |
| O0600B3 |         21 |         19 |            |
+---------+------------+------------+------------+

Can I do this just by using sql and not adding php, perl, or any
other language?


---------------------------------------------------------------------
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Reply via email to