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 2005 Forums
 Transact-SQL (2005)
 Opening balence and closign balence
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gangadhara.ms
Aged Yak Warrior

India
547 Posts

Posted - 11/06/2012 :  03:51:51  Show Profile  Reply with Quote
Hi All,
I have a table which i need to find out the Opening balance and closing balance for the sales team for the last 1 week.

-- Get what Rep has been SHIPPED
SELECT mo.Material_ID, ss.BatchNumber,SUM(ss.Quantity) as [Shipped], ExpiryDate
FROM Material_Order_Sample_Shipment ss
JOIN Material_Order mo ON mo.ID = ss.Material_Order_ID
WHERE mo.Rep_ID = @Rep_ID AND ss.Material_Order_ID IN (SELECT ID FROM Material_Order WHERE Status_ID = 2 AND
datereceived >=dateadd(dd,-7,getdate()))
GROUP BY ss.BatchNumber, mo.Material_ID, ExpiryDate
ORDER BY mo.Material_ID

Please help me to get the query to get the transaction for 1 week.

Or any suggestion welcome.

Regards,
Gangadhara


Thanks,
Gangadhara MS
SQL Developer and DBA

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 11/06/2012 :  12:33:10  Show Profile  Reply with Quote
Your question is vague. Without knowing data in your table and concept of trsnsaction for you nobody will be able to provide you with accurate solution

Post some sample data as per below and somebody will be able to help

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

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.07 seconds. Powered By: Snitz Forums 2000