Hi All,
Happy 2007 Tek-Tippers!!
I have a generic "is it possible?" SQL query. If possible I will need to use any solutions in postgreSQL and SQL Server 2000.
I have a table that contains Order information - let's call it tblOrders for the sake of originality. Every row represents a unique order, and contains order_number, order_date and customer_id.
What I want to do is write a query that will return 1 row for every customer with the order_number of their 1st order. Unfortunately order_number is not always sequential so i can't take min(order_number). I need to return the order_number for min(order_date) for each customer.
I have tried anbsolutely every combo of WHERE, GROUP BY and HAVING clauses, and our internal guru's are saying they doubt it can be done without a stored proc - I jsut can't believe it can't be done!!
Please, if anyone can possibly help, or confirm for certain that it can't be done, I will sleep a lot easier!!
Many thanks to anyone who can help,
NixyJ x
Happy 2007 Tek-Tippers!!
I have a generic "is it possible?" SQL query. If possible I will need to use any solutions in postgreSQL and SQL Server 2000.
I have a table that contains Order information - let's call it tblOrders for the sake of originality. Every row represents a unique order, and contains order_number, order_date and customer_id.
What I want to do is write a query that will return 1 row for every customer with the order_number of their 1st order. Unfortunately order_number is not always sequential so i can't take min(order_number). I need to return the order_number for min(order_date) for each customer.
I have tried anbsolutely every combo of WHERE, GROUP BY and HAVING clauses, and our internal guru's are saying they doubt it can be done without a stored proc - I jsut can't believe it can't be done!!
Please, if anyone can possibly help, or confirm for certain that it can't be done, I will sleep a lot easier!!
Many thanks to anyone who can help,
NixyJ x