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 2000 Forums
 SQL Server Development (2000)
 Group By clause

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-27 : 11:15:41
Augustin Prasanna writes "Hi,

I have a requirement. i have a table called TblGoodsReceived. i need to generate a query such that it returns the sum of goods received between any 2 dates grouped by ItemId. Also, simulataneously, i need to display the received dates in a comma separated manner (for each ItemId). is this possible in a single query? which is the best way to go abt it other than using temporary tables & cursors?

Sql Version : MS SQL Server 7.0
Windows: Windows NT 4.0

Thanks,
prasanna"

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-03-27 : 11:17:55
1) post your ddl ( table definitions ).

2) refer to http://www.sqlteam.com/item.asp?ItemID=2368 for a very good treatment of creating comma-delimited lists.

setBasedIsTheTruepath
<O>
Go to Top of Page

augustin_p
Starting Member

21 Posts

Posted - 2002-03-29 : 04:15:53

Hi,
Below is my table defn.

Table : TblGoodsReceived

Id: int (identity)
RecdDate: Datetime
ItemId: numeric
QtyRecd: numeric

i need to display total received qty for an item between any two dates and also received dates like in below format

ItemId Qty Dates
------- --- ---------
01 200 1 Mar 2002, 3 Mar 2002, 5 Mar 2002


Hope you got my point. i want to do this without using cursors.

Thanks,
prasanna
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-03-29 : 07:11:54
Try this:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=9978

Go to Top of Page
   

- Advertisement -