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 |
|
vgr.raju
Yak Posting Veteran
95 Posts |
Posted - 2005-06-16 : 03:55:16
|
| I am working with northwind database.I want to select the customername,their orderid,orderdetails,price,total.I wanted to my display of results appear the following way.CustomernameOrders[one customer has multiple orders]orderdetails[one order has multiple details]pricequantitytotal.I am having difficulty passing multiple values into one row.Is it possible to declare some variables and pass values using groupby clause.I would greatly appreciate your help in this regard. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-16 : 04:54:49
|
| You need to join Customers and Orders tableLook for Joins in Books On LineMadhivananFailing to plan is Planning to fail |
 |
|
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2005-06-16 : 05:16:17
|
| sounds like you are taking a class on this, right?if this is the case, we don't really want to tell you the answer. We will just nudge you in the right direction so you can figure it out on your own. Learning is better that way..You can start by posting the query that you have come up with. Even if it doesn't work, post what you have.-ec |
 |
|
|
vgr.raju
Yak Posting Veteran
95 Posts |
Posted - 2005-06-17 : 04:57:39
|
select c.customerid,c.contactname,o.orderid,o.orderdate,o.shipaddress,od.productid,od.quantity,od.unitprice,od.unitprice*od.quantity as GrandTotal, p.productnamefrom customers cjoin orders o on c.customerid = o.customeridjoin [order details] od on o.orderid = od.orderidjoin products p on p.productid=od.productidThis is the query I have.What I wanted to do is to get one row with customername,all their orders,orderdetails,and total price.Wanted to pass one to many relationships into single row with some delimiter.I understand this is not the rdbms concept of doing things.Just wanted to learn.I greatly appreciate your help in this regard.Thanks.quote: Originally posted by vgr.raju I am working with northwind database.I want to select the customername,their orderid,orderdetails,price,total.I wanted to my display of results appear the following way.CustomernameOrders[one customer has multiple orders]orderdetails[one order has multiple details]pricequantitytotal.I am having difficulty passing multiple values into one row.Is it possible to declare some variables and pass values using groupby clause.I would greatly appreciate your help in this regard.
|
 |
|
|
|
|
|
|
|