All pastes #465056 Raw Edit

Untitled

public text v1 · immutable
#465056 ·published 2007-04-29 21:52 UTC
rendered paste body
SELECT `user_id` AS `Account Number`,
					`line_item_date` AS `Service Date`,
					`service_name` AS `Service Type`,
					`line_item_end_user_price` AS `Total Before Tax`,
					`line_item_gst` AS `GST`,
					`line_item_hst` AS `HST`,
					`line_item_pst` AS `PST`,
					`line_item_gst`/`line_item_end_user_price` AS `GST Rate`,
					`line_item_hst`/`line_item_end_user_price` AS `HST Rate`,
					`line_item_pst`/`line_item_end_user_price` AS `PST Rate`,
					`line_item_end_user_price` + `line-item_gst` + `line-item_hst`+ `line-item_pst` AS `Total Charge`
				FROM `LNE_Line_Item` `SCH_Appointment`, `SRV_Service`
				WHERE LNE_Line_Item.`appointment_id`=SCH_Appointment.appointment_id
					AND  SCH_Appointment.service_id = SRV_Service.service_id
					AND line_item_status = 'Charged'

ERROR 1054 (42S22): Unknown column 'LNE_Line_Item.appointment_id' in 'where clause'

mysql> DESC LNE_Line_Item;
+---------------------------+----------------------------------+------+-----+---------+----------------+
| Field                     | Type                             | Null | Key | Default | Extra          |
+---------------------------+----------------------------------+------+-----+---------+----------------+
| line_item_id              | int(10) unsigned                 | NO   | PRI | NULL    | auto_increment |
| appointment_id            | int(10) unsigned                 | NO   |     |         |                |
| line_item_name            | varchar(64)                      | NO   |     |         |                |
| line_item_date            | date                             | YES  |     | NULL    |                |
| line_item_status          | enum('Pending','Void','Charged') | NO   |     |         |                |
| line_item_description     | text                             | NO   |     |         |                |
| line_item_notes           | text                             | NO   |     |         |                |
| line_item_end_user_price  | decimal(8,2)                     | NO   |     | 0.00    |                |
| line_item_discount        | decimal(8,2)                     | NO   |     | 0.00    |                |
| line_item_gst             | decimal(8,2)                     | NO   |     | 0.00    |                |
| line_item_hst             | decimal(8,2)                     | NO   |     | 0.00    |                |
| line_item_pst             | decimal(8,2)                     | NO   |     | 0.00    |                |
+---------------------------+----------------------------------+------+-----+---------+----------------+
12 rows in set (0.05 sec)


Even this query fails:

SELECT 
`service_name`,
`line_item_end_user_price`
FROM `LNE_Line_Item` `SCH_Appointment`, `SRV_Service`
WHERE LNE_Line_Item.appointment_id=SCH_Appointment.appointment_id
AND  SCH_Appointment.service_id = SRV_Service.service_id


ERROR 1054 (42S22): Unknown column 'LNE_Line_Item.appointment_id' in 'where clause'