Please start any new threads on our new site at http://forums.sqlteam.com. 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
 
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
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gangadhara.ms
Aged Yak Warrior

India
549 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
52326 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  
 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.44 seconds. Powered By: Snitz Forums 2000