This topic is locked
[SOLVED]

 sql help query needed..

10/28/2010 6:22:05 AM
PHPRunner General questions
T
tedwilder author

hello
because I'd like to use the chart feature I need to do some advanced sql queries ( at least advanced to me ).
I have a table with orders. it contains iditem from table item. it contains idcustomers from customers.

table item contains iditem, description field.

table customer contains idcustomer,name fields.

I would like to view how many item has been sold on a specific time.
so I tried :

SELECT COUNT(iditem)

FROM

orders

GROUP BY

orders.iditem
al i get is 3 line ( because only 3 different items are in the order database).returning the number of each item.
what i would like is result like that
(description of item) : ( number of item ordered )

nameofitem1 : 12

nameofitem2 : 52

...
and then

to to do another chart with same result as above but based on customer . ( im quite sure it's about some thing with flags on help files : it shows color flags based oncustomer id. that would be something like that ).
thank you.

T
tedwilder author 10/28/2010

Ok I resolved the problem.

SELECT COUNT(order.iditem),item.description

FROM

order,item

Where order.iditem=item.iditem

GROUP BY

order.iditem

T
tedwilder author 10/29/2010



Ok I resolved the problem.

SELECT COUNT(order.iditem),item.description

FROM

order,item

Where order.iditem=item.iditem

GROUP BY

order.iditem



well problem is not exactly solved as phprunner query builder reset my query ... see video file.
video file

T
tedwilder author 10/29/2010

I think I solved it. COUNT is under "group by" columm.. still this behavior is very strange.