Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group by problem 1

Status
Not open for further replies.

juuso79

Programmer
Nov 15, 2001
22
FI
Hi what is wrong in this line.

mysql_query("CREATE TABLE shipments2 TYPE=HEAP SELECT ID_number, count(On_time) FROM Shipments WHERE On_time = 1 GROUP BY ID_number");

Im trying to count how many On_time rows is there with the number 1 in it. According to ID_number. Im using PHP/MySQL/Apache.

I have for example this kind of Shipments -table:

ID_number On_time
12345 1
12345 1
12345 0
12345 1
22222 0
22222 1
22222 1

And I want new table to be like this:

ID_number On_time
12345 3
22222 2


Thanks in advance!!!
 
Not entirely sure about the type being set like this, with it removed does the query execute correctly.

mysql_query("CREATE TABLE shipments2 SELECT ID_number, count(On_time) FROM Shipments WHERE On_time = 1 GROUP BY ID_number");
______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top