Hello Shazia, Friday, July 11, 2003, 10:25:56 PM, you wrote:
This is a tipical CROSSTAB QUERY. http://www.mysql.com/articles/wizard/print_version.html You also can use MS Access wich automatically suports crosstab query, to make this kind of report SF> Hi: SF> I have a table with one column as AppointmentID and for each AppointmentID I have multiple Payments. The table looks like this: SF> AppointmentID Payment SF> 123 100 SF> 123 50 SF> 123 200 SF> 124 30 SF> 124 100 SF> Now i want to write a MySql query which will retrieve all the payments corresponding to a particular AppointmentID .. the result should eb like this: SF> AppointmentID Payment1 Payment2 Payment3 Payment4 SF> 123 100 50 200 0 SF> 124 30 100 0 0 SF> since the number of payments for each appointmnet vary, I calculate 4 payments(there are a max of 4 payments for an appointmentId) SF> I tried using Max and Min function but what about the rest which are in between the Max and Min. SF> Somebody help me out..i can't use subqury or union as i am using Mysql 3 -- Best regards, Krasimir_Slaveykov mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]