SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Select Query in Northwind Database
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sharath_ms
Starting Member

3 Posts

Posted - 03/13/2013 :  09:53:07  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
6062 Posts

Posted - 03/13/2013 :  14:29:05  Show Profile  Reply with Quote
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 - 03/14/2013 :  09:11:50  Show Profile  Reply with Quote
Thanks for help
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000