I am trying to fetch data between the (max date in the entrydate column) and (max date in the entrydate column-15days)!!
Table1:Totally it has 953rows

Table2: Totally it has 400rows

i got this error ,Please help me !!
Select
o_material_transaction_inward.Mat_Code,
s_material_details.Mat_Spec,
s_material_details.Mat_Make,
o_material_transaction_inward.Sup_Name,
o_material_transaction_inward.Entry_Date,
o_material_transaction_inward.DC_qty,
o_material_transaction_inward.Received_qty,
from
o_material_transaction_inward
join
s_material_details
on
s_material_details.Mat_Code=o_material_transaction_inward.Mat_Code and s_material_details.Mat_Group_Id=o_material_transaction_inward.Mat_Group_id
where
o_material_transaction_inward.Entry_Date between Max(o_material_transaction_inward.Entry_Date) and Max(o_material_transaction_inward.Entry_Date - 15)
Update: Fixed
BETWEENpredicate:The reason it wasn’t working is that the lowest value need to be the first value in the
BETWEENpredicate, so in order to get those rows from the two tables having theentry_datebetween the max entry date – 15 and max entry date try this:SQL Fiddle Demo