need help with record fetch from SQL server 
Author Message
 need help with record fetch from SQL server

Hi all,

I have following table and sample data in sql server 7.0(sp3) (this table
belongs to someone else and I cannot change design. Below I have gave only
the required fields from that table . )

ID TYPE CODE AMOUNT LINENR
111 0         901         10000         1
112 0         902         15000         2
113 2         0               1500         3
114 0         903         30000         4
115 2         0               3000         5
116 2         0               1500         6
117 0         904         40000         7

I want to make this ouput using this table
ID TYPE CODE AMOUNT LINENR   DAMOUNT
111 0         901         10000         1                0
112 0         902         15000         2                1500
114 0         903         30000         4                4500
117 0         904         40000         7

DAMOUNT is the sum of AMOUNT at rows where TYPE=2 and it is related with the
preceding first row with TYPE=0. Unfortunately, there are no other relations
with TYPE=0 and TYPE=2 fields.

I am planning to use VB 6 (and hope VB.NET) , so is there anyone who can
show me way to this? As I want to show this data on web and share with some
other applications, I dont want to use recordset loops and vice versa. I
want to know if it is possible using stored procs, T-SQL stats or XML to
derive the second output (desired) from the first table ?

Thanx advance

Ertug



Mon, 17 May 2004 21:43:09 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. need help with copy .dbf records to SQL server

2. displaying sql server records need help

3. Need Record locking help on SQL server and VB6

4. fetching tape drives that are installed on a SQL Server

5. need ID from newly inserted record (altered by insert trigger on SQL server)

6. Problem seeking for records with ADO and SQL Server, Please Help

7. HELP: delete record on SQL server

8. Problem seeking for records with ADO and SQL Server, Please Help

9. Problem seeking for records with ADO and SQL Server, Please Help

10. Easy way to copy Multiple Records from MDB on pc to SQL Server on Server

11. Need help getting records from SQL

12. Conceptual Help Needed for SQL Server and MSDE

 

 
Powered by phpBB® Forum Software