Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 DATEADD

Author  Topic 

DeNam
Starting Member

15 Posts

Posted - 2013-08-19 : 05:01:00
Hi,

I cant add a dateadd statement to the following code. Is it because
(select date from vfa_uppf..RISKP_DATE) includes numerous rows?


select COUNT(*),
CASE WHEN RES_kb_scoring NOT IN ('1','2','3','4','5') THEN 'DEF' ELSE RES_kb_scoring END as Score,
RES_datum
from VFA_UPPF..Reservering
where RES_datum in (DATEADD(day, 1, select date from vfa_uppf..RISKP_DATE)) and RES_ao=500 and RES_produkt='Lån'
group by CASE WHEN RES_kb_scoring NOT IN ('1','2','3','4','5') THEN 'DEF' ELSE RES_kb_scoring END, RES_datum
order by RES_datum, Score

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-08-19 : 05:12:00

where RES_datum in (select DATEADD(day, 1, date) from vfa_uppf..RISKP_DATE)


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

ShivaKrishna
Starting Member

20 Posts

Posted - 2013-08-29 : 08:16:47
1st... RES_datum in (select DATEADD(day, 1, date) from vfa_uppf..RISKP_DATE)

we can also use below code:
2nd.....dateadd(day,-1,RES_datum) in(select date from vfa_uppf..RISKP_DATE)

2nd is not recommended as it reduces performance
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-08-30 : 00:31:32
you could also use a join


...
from VFA_UPPF..Reservering r
join vfa_uppf..RISKP_DATE rd
ON r.RES_datum = rd.[date] + 1
...


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -