Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


adding specific column data w.rto date, where TOTAL_ELECTRONIC_VALUE which s already added


adding specific column data w.rto date, where TOTAL_ELECTRONIC_VALUE which s already added

Author
Message
anushamsbi
anushamsbi
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 15
Pls help me with this issue..
this is my query
SELECT
PROCESSING_DATE,
[ACL_BALANCE_CM] =SUM(TOTAL_ELECTRONIC_VALUE)

FROM ODS.FUNDS_POOL_BALANCE
WHERE PROCESSING_DATE between '16-May-2012' and '28-May-2012'
and PROCESSING_DATE=CONVERT(VARCHAR(10),DATEADD(d,-1,'17-May-2012'),101)
group by PROCESSING_DATE
order by 1

which is generating result as PROCESSING_DATE-
ACL_BALANCE_CM-653215.42 ( which s added column(TOTAL_ELECTRONIC_VALUE) with respect to date. that means if for date '16-May-2012' there are 2 entries then with this above query, it will add all the columnvalues for tat particular date from the actual table .


This is fine.,
Now my requirement s if i give PROCESSING_DATE= '17-May-2012' i need to add [ACL_BALANCE_CM] for processing date and the previous date ...(eg.'17-May-2012' ,'16-May-2012' )

Actually [ACL_BALANCE_CM] is coming from SUM(TOTAL_ELECTRONIC_VALUE-- which is the actual column name in the table)
Now again i need to add this [ACL_BALANCE_CM] for the date which i have given and its previous one

My thought s only we can achieve this with cursors only, bcoz sum(column name) means it will add all the column data, but only for some particular rows only i need to add data .. i am confused...
Please give me quick respone. (if u also suggests it can be achivable with cursor only, then i need related code, as am fully new to cursors)

Responded people are highly appreciated, thanks in advance.
Sean Lange
Sean Lange
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16550 Visits: 17004
Definitely do not need a cursor for this.


declare @ProcessingDate date = '17-May-2012'


PROCESSING_DATE > dateadd(d, @ProcessingDate, -1)
and PROCESSING_DATE <= @ProcessingDate




If that doesn't point you in the right direction, take a look at the first link in my signature for best practices when posting questions.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
anushamsbi
anushamsbi
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 15
Hi,
It is not working.. can u pls eloborate that one..
Phil Parkin
Phil Parkin
SSCrazy Eights
SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)SSCrazy Eights (8.3K reputation)

Group: General Forum Members
Points: 8324 Visits: 19471
anushamsbi (8/17/2012)

Hi,
It is not working.. can u pls eloborate that one..


Rather than saying "it's not working", which is close to useless to us, please provide details of what you tried and the text of any error messages you received.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Sean Lange
Sean Lange
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16550 Visits: 17004
anushamsbi (8/17/2012)

Hi,
It is not working.. can u pls eloborate that one..


Can you elaborate on "It is not working"? What does that mean? Did you get an error message? Did it not return the desired results?


If that doesn't point you in the right direction, take a look at the first link in my signature for best practices when posting questions.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Lynn Pettis
Lynn Pettis
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24179 Visits: 37948
What?? Does NOONE have a working crystal ball?? w00t

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search