Sorry I don't know how to put it in title, I have this query on an aspx page with 2 datepickers (let's say data and data2)
select utenti.nome as tecnico, Richieste.IDRic as idchia, richieste.descr as rdescr, ISNULL(richieste.assistremota,0) as assremota, Clienti.RagSociale as ragsoc, richieste.descr as descr, richieste.priorita as prior, richieste.tipo as tipo, richieste.rforologio as rforo, ISNULL(statoric.appuntamento,0) as app, ISNULL(statoric.oradalle,0) as dalle, ISNULL(statoric.oraalle,0) as alle, statoric.ID as idstato
from clienti
inner join richieste on clienti.idcliente = richieste.rfcliente
inner join statoric on statoric.rfric = richieste.idric
inner join stati on stati.idstato = statoric.rfstato
inner join utenti on utenti.idutente=statoric.rftecnico
where statoric.attuale = 1 and statoric.rfstato < 14 and statoric.dataass = @data and statoric.rftecnico = 8 order by app desc, oraalle asc, prior desc
I need to change the "statoric.dataass = @data" part to do this (pseudocode):
if data 2 is null then
"statoric.dataass = @data"
else
"statoric.dataass between @data and @data2"
end if
How can I do it? I tried case and If but I'm doing something wrong... thanks