Script/ query help

I Want to achieve the following :
Could I please have the following Gender 'Female' and email address lists for UK customers only and

  1. Customers who have purchased 1+ times within the last 13 months & has made 4+ orders throughout their lifetime & the order value of their purchases is £55+
  2. Customers who have purchased 1+ times within the last 13 months & have made 6+ orders throughout their lifetime & the order value of their purchases is £10-54
  3. Customers who have purchased 1+ times within the last 13 months & have made 2-5 orders throughout their lifetime & the order value of their purchases is £10-54

I have got this script but does not know to how to achieve the above.

SELECT
[Order Guid]
,[Sell-to Customer No_]
,[Bill-to Name]
,[Order Date]
,[Amount]
,[Ship-to Country Code]
,[Internet Order Reference]
,[Handling Amount]
,[Original Order No_]
,[E-Mail]
,[Gender]
,IC.[Phone No_]
,IC.[Phone No_]
,[Last DateTime Modified]
,[Last DateTime Processed]
,[Date First Ordered]
,[Date Last Ordered]

 FROM [TBW_BI].[dbo].[dreams Trading$Internet Order Header] AS OH
INNER JOIN [TBW_BI].[dbo].[dreams Trading$Internet Customers] AS IC 
 ON IC.[Customer No_]=OH.[Sell-to Customer No_]
 WHERE 
[order date] >= '2016-02-01T00:00:00.000' AND 
[order date] <= '2017-03-31T00:00:00.000' AND [Ship-to Country Code]='UK' AND [Gender]='2'

ORDER BY [order date] ASC

I have no idea which table the listed columns are in, and I'm not going to guess. Without knowing that, it's impossible to write SQL code.

1 Like