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 2005 Forums
 Transact-SQL (2005)
 Stored procedure

Author  Topic 

vijayanto
Starting Member

16 Posts

Posted - 2009-06-02 : 00:29:44
hi friends,
i got the problem in the stored procedure
i have fields like date and quantity
for the current date i have quantity
but at the same time i want to display the quantity depending on the previous date
please give me the solution

regards,
vijay

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-02 : 00:33:08
Homework?

SELECT SUM(Quantity)
FROM Table1
WHERE Date >= DATEDIFF(DAY, 1, GETDATE())
AND Date < DATEDIFF(DAY, 0, GETDATE())



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-06-02 : 00:34:04
will u update ur table structure and expected output?


Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled
Go to Top of Page

vijayanto
Starting Member

16 Posts

Posted - 2009-06-02 : 00:49:30
Thanks
Go to Top of Page

SQLRatankalwa
Starting Member

42 Posts

Posted - 2009-06-02 : 02:57:25
You Can also do it

SELECT SUM(Quantity)
FROM Table1
WHERE Date Between Getdate() -1 AND GetDate()

using the above method.

Ratan Kalwa
SQL Server Professionals User Group

http://www.revalsys.com
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-02 : 02:59:50
quote:
Originally posted by SQLRatankalwa

SELECT SUM(Quantity)
FROM Table1
WHERE Date Between Getdate() -1 AND GetDate()
Also if there is time information in the Date column?


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -