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 2008 Forums
 Transact-SQL (2008)
 Select Query in Northwind Database

Author  Topic 

sharath_ms
Starting Member

3 Posts

Posted - 2013-03-13 : 09:53:07
Hi All-

I'm learning OLAP modelling.In this context i have decided to use northwind database for creating Star schema.I want to select the below fields using Northwind database,these fields will be used to create Order fact table.

OrderID,ProductID,UnitPrice,Quantity,Discount,Customer ID,Employee ID,Supplier and Order Date.

I tried querying using the below query.However,as am not good at SQL i'm unable to fine tune this query.

SELECT distinct
o.OrderID,
od.Quantity,
od.UnitPrice,
e.EmployeeID,
p.ProductID
s.SupplierID

from [Order Details] od inner join Orders o on od.OrderID=o.OrderID ,
Employees e JOIN Orders ON (e.EmployeeID = Orders.EmployeeID),
Products p JOIN Suppliers ON (p.ProductID= Suppliers.SupplierID)
Suppliers S JOIN Products ON (S.SupplierID = Products.SupplierID).

Can someone provide me correct query to pull the above mentioned field.

Thanks for your help in advance.

Regards
SSM

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-03-13 : 14:29:05
I don't have the Northwind database but I'm guessing you want something like this for your FROM clause.

from orders o
inner join orderDetails od
on od.orderid = o.orderid
inner join products p
on p.productid = od.productid
inner join suppliers s
on s.supplierid = p.supplierid
inner join Employees e
on e.EmployeeID = o.EmployeeID


Be One with the Optimizer
TG
Go to Top of Page

sharath_ms
Starting Member

3 Posts

Posted - 2013-03-14 : 09:11:50
Thanks for help
Go to Top of Page
   

- Advertisement -