TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Pravin Ghadge
563
2.1k
586.7k
Sql Querry
Apr 24 2012 2:42 AM
Dear all,
I am trying to get net figure using variable.
declare @ConsAcct as nvarchar(1000)
set @ConsAcct =(select distinct substring((select ''''+ AcctCode + ''',' from oact y where y.fathernum='502000' for xml path('')),0,LEN((select ''''+AcctCode + ''',' from oact y where y.fathernum='502000' for xml path('')))) from oact x)
---this gives me '502100','502200','502300','502400','503000' in @ConsAcct variable
select sum(Debit) from jdt1 inner join oact on jdt1.account=oact.acctcode where
oact.fathernum in (@ConsAcct)
O/P:NULL
but after runnning querry it gives me 'NULL' result
But when i run same query only in place of variable i have hardcoded the no's its give me proper result
select sum(Debit) from jdt1 inner join oact on jdt1.account=oact.acctcode where
oact.fathernum in ('502100','502200','502300','502400','503000')
O/P:54000
I can't understand what may be the reason....
Plz give me some solution
Reply
Answers (
6
)
Aggregate Functions in SQL SERVER 2008
Stored Procedure