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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-04-04 : 07:57:50
|
| Sangram Patil writes "We are using Asp.NET & SQL SERVER 2000 to build a shoppingcart.I dont know how to put it technically so i'll try my best explain its logic.we have 2 tables Orders and SubOrders.Orders table has 2 fields ID & Total.SubOrders has 3 fields SID, OrderID & DetailsThe relationship b/n the 2 tables is Orders.ID=SubOrders.OrderID the following is the sample data:OrdersID Total----------1 102 20SubOrdersSID OrderID Details----------------------------1 1 Details12 1 Details23 2 Details34 2 Details45 2 Details5Now we want to frame a query which returns results as follows.RESULTS:ID SID Details Total----------------------------------------1 1 Details1 102 1 Details2 00 3 2 Details3 204 2 Details4 005 2 Details5 00I hope ypu guys have understood my Problem.I have tried my best to explain it to you.And thanks in advance" |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-04-04 : 08:31:41
|
I did not understand Your problem.I think that You should not store Total in Orders table like You do.If You join Orders & SubOrders given the sample data You WILL get:ID SID Details Total----------------------------------------1 1 Details1 102 1 Details2 103 2 Details3 204 2 Details4 205 2 Details5 20 If that is not what You want, You have a bad design.rockmoose |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2005-04-04 : 08:40:12
|
| Indeed, I couldn't figure this one out. For the same ID you want to bring back a different total? Sorry but that makes no sense.-------Moo. :) |
 |
|
|
|
|
|