Why I obtain this "Incorrect syntax near the keyword 'between'" into a SQL Server query that use between? -
i not familiar databases.
i working on microsoft sql server , have problem trying perform query uses between keyboard select date range.
my query is:
select numeropolizza ,sum(v.ctv) ctv_ri ( select r.numeropolizza,sum(r.importoprestazioneiniziale) ctv prestazione r with(nolock) r.numeropolizza in (select id polizza p with(nolock) tiposistemaprovenienzaid=8) --and r.datainizio <= '2015-12-31' , between '2016-01-01' , '2016-04-01' group r.numeropolizza union select numeropolizza,sum(importorivalutazionedapiano+importorivalutazioneestemporaneo)as ctv rivalutazione with(nolock) numeropolizza in (select id polizza p with(nolock) tiposistemaprovenienzaid=8) --and datadecorrenza <= '2015-12-31' , between '2016-01-01' , '2016-04-01' group numeropolizza ) v group numeropolizza order numeropolizza
as can see using 2 between filter of 2 where conditions, this:
and between '2016-01-01' , '2016-04-01'
the problem sql server give me following error message:
11:30:36 [select - 0 row(s), 0.000 secs] [error code: 156, sql state: s0001] incorrect syntax near keyword 'between'. ... 1 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.000/0.000 sec [0 successful, 0 warnings, 1 errors]
what missing? how fix issue?
you miss column name before between.
syntax <column_name> between <value> , <other_value>
Comments
Post a Comment