I am using the following query to grab delivery types from an SQL database, the query gets all delivery types associated with the list of products in the shopping cart. The query could return a minimum of two delivery types for one product or many more for multiple products within the cart. However i just need the two most expensive delivery cost to be displayed.
E.G.
Product 1 has Std Delivery £9.99 AND 2 Man delivery £29.99
Product 2 has Std Delivery £18.95 AND 2 Man Delivery £39.99
I need to display to the screen the delivery types for product 2. Can i use the max function or will that only return the highest delivery price?
Query being used:
<cfquery name="getDeliveryType" datasource="#application.dsn#">
SELECT
uid_pdelopt,
txt_pdelopt_type,
mon_pdelopt_cost,
uid_pdelopt_prodid,
txt_pdelopt_detail,
bit_pdelopt_active,
bit_pdelopt_selected,
uid_pdelopt_webid,
uid_pdelopt_typeid,
mon_pdelopt_actcost
FROM dbo.tbl_product_deliveryopt
WHERE bit_pdelopt_active=<cfqueryparam cfsqltype="cf_sql_bit" value="yes">
AND uid_pdelopt_prodid IN (<cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.uid_pdelopt_prodid#" list="yes">)
</cfquery>
Any pointers would be appreciated.
Jason
You can order by cost DESC and limit the results to 2