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
 General SQL Server Forums
 New to SQL Server Programming
 Using String Functions and Aggregate Functions
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AegelisX15
Starting Member

1 Posts

Posted - 03/07/2014 :  19:04:45  Show Profile  Reply with Quote
I am still a noob when it comes to SQL. I am using SQL Server Management Studio.

I am searching through over a million records and I only need 7 to pop up.
- I can use String functions and/or aggregate functions. The only problem is I don't know how to use them.


My query below.

SELECT OrderID, c.CompanyName, FirstName + ' ' + LastName AS 'Emp Name', s.CompanyName, OrderDate
FROM Orders, customers c, Employees, Shippers s
WHERE (OrderID > 10999 AND OrderID < 11007) AND Orderdate = 1998
ORDER BY OrderID

If I take the "AND Orderdate = 1998" out then A query shows up but not the one im looking for.

Please help me. I have no idea where I am with this. I just hit the SQL WALL.

tkizer
Almighty SQL Goddess

USA
37446 Posts

Posted - 03/07/2014 :  19:23:27  Show Profile  Visit tkizer's Homepage  Reply with Quote
You didn't add any join conditions. I'm confused why you are asking about aggregate function but didn't include any in your query.

Please post some sample data so that we can help.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

maunishq
Yak Posting Veteran

Canada
71 Posts

Posted - 03/10/2014 :  15:50:27  Show Profile  Reply with Quote
tkizer is correct.
Please add join conditions. e.g.
SELECT OrderID, c.CompanyName, FirstName + ' ' + LastName AS 'Emp Name', s.CompanyName, OrderDate
FROM Orders, customers c, Employees, Shippers s
ON Orders.OrderID = c.OrderID
AND Orders.OrderID = Employees.OrderID
AND Orders.OrderID = s.OrderID
WHERE (OrderID > 10999 AND OrderID < 11007) AND Orderdate = 1998
ORDER BY OrderID

=======================
Not an Expert, Just a learner.
!_(M)_!
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