Building CAML queries in SharePoint is not so easy, especially making complex queries using parameters etc.
Well there are tools available in the internet that can help. But maybe you have a tool at hand you didn’t think of immediately ?
Report Builder can do the job :
Open a new report and link to the SharePoint List you want to attack.
Open the Query Designer
Select the fields you need and click on the FILTER icon. Add your Filter Field and check the PARAMETER box.
Run the Query to test it, and if OK click EDIT as TEXT
And voila your CAML Query is properly formatted !