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
 Transact-SQL (2000)
 Hello

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.
Customername
Orders[one customer has multiple orders]
orderdetails[one order has multiple details]
price
quantity
total.
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 table
Look for Joins in Books On Line

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

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
Go to Top of Page

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.productname
from customers c
join orders o on c.customerid = o.customerid
join [order details] od on o.orderid = od.orderid
join products p on p.productid=od.productid

This 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.
Customername
Orders[one customer has multiple orders]
orderdetails[one order has multiple details]
price
quantity
total.
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.


Go to Top of Page
   

- Advertisement -