Jump to content

Query Help


abrahamgarcia27

Recommended Posts

I can't seem to figure out how to structure the following query. 

 

I have two type of content

 

1= helmet

2 = shoulder pads

 

and i have grouped it by school_barcode it gives me all the rows in one result which is what i want. But now i want it to SUM all the count where the type is 1 and type is 2 and give me two different results. 

 

I have this table

 

detail_id

school_barcode

bag_number

type_content

count

receiving_id

freight_bill

time_stamp

 

and have the following query

		$sql = "SELECT SUM(count), `".TABLE_RECEIVING_DETAIL."`.school_barcode, `".TABLE_SCHOOL."`.name FROM `".TABLE_RECEIVING_DETAIL."` LEFT JOIN `".TABLE_SCHOOL."` on  `".TABLE_RECEIVING_DETAIL."`.school_barcode = `".TABLE_SCHOOL."`.bar_code WHERE receiving_id = '$receiving_id' AND freight_bill = '$freight_bill' GROUP BY school_barcode";

The end result should be

 

Customer # | Cutomer Name | Helmets Received SUM | Shoulder Pads Received SUM 

Link to comment
https://forums.phpfreaks.com/topic/283900-query-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.