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)
 simple select

Author  Topic 

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2004-12-14 : 09:10:07
Hey all,

Im suffering from mind block today so if anyone can help this is what I am trying to acheive...

One contains information about suppliers and the other contains information about orders...

I would like to look at all the suppliers who have made an order in the past year and create a spreadsheet with their contact information...

I can get the data I need however there are mutlitple instances of the same data as the select statement is creating an instance for every date it sees that meets my criteria, even if I already have it... I cant for the life of me work out how I am to include the TOP funtion to my statement... please can you help?

So here is my statement as it looks at the minute:

SELECT Suppliers.CompanyName, Suppliers.Add1, Suppliers.Add2, Suppliers.Add3, Suppliers.Add4, Suppliers.PostCode, Porders.date
FROM Suppliers INNER JOIN Porders ON Suppliers.Code = Porders.SupplierCode
WHERE (((Porders.Date) Between #1/1/2004# And #12/31/2004#));

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-12-14 : 09:13:09
Just need a DISTINCT:

SELECT DISTINCT Suppliers.CompanyName, Suppliers.Add1, Suppliers.Add2, Suppliers.Add3, Suppliers.Add4, Suppliers.PostCode, Porders.date
FROM Suppliers INNER JOIN Porders ON Suppliers.Code = Porders.SupplierCode
WHERE (((Porders.Date) Between #1/1/2004# And #12/31/2004#));


This is Access SQL BTW.
Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2004-12-14 : 11:00:50
lol I know yeah, we havent changed over to sql server yet... though we have it there, moving the connections is a bit of a pain... I started here as a grunt who makes pc's and now ive been landed with this 130+ tables database :S trying to learn so much all at the same time...

Thanks all the same =)

edit: did the #'s give the game away
Go to Top of Page
   

- Advertisement -