I have got a following query which counts the number of orders for last week for seven sites. If there is no order for a given site in last week it display 0 rather than not displaying the site at all, hence the reason i am using the Case statement. All well and good, the challenge is that for a given date lets say 21/04/2014 if there are more than one orders for the site, my query shoudl only condsider one record , so for site4 the count value is 4 but it should be 3, the reason its 4 is because on 21st of this week it got two order entries. is there any way i could only add 1 site for given day if more than two orderdates are found for that date? i was considering using min(orderdate), but sql gives me errors that i cannot use aggregate function in a subquery or aggregate function.I have got a following query which counts the n