SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 DATEADD
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

DeNam
Starting Member

Sweden
15 Posts

Posted - 08/19/2013 :  05:01:00  Show Profile  Reply with Quote
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)

Singapore
17431 Posts

Posted - 08/19/2013 :  05:12:00  Show Profile  Reply with Quote

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


KH
Time is always against us

Go to Top of Page

ShivaKrishna
Starting Member

India
20 Posts

Posted - 08/29/2013 :  08:16:47  Show Profile  Reply with Quote
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

India
52249 Posts

Posted - 08/30/2013 :  00:31:32  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000