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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

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

Starting Member

15 Posts

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

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,
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

In (Som, Ni, Yak)

17689 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)

Time is always against us

Go to Top of Page

Starting Member

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

Very Important crosS Applying yaK Herder

52326 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
Go to Top of Page
  Previous Topic Topic Next 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.03 seconds. Powered By: Snitz Forums 2000