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
 General SQL Server Forums
 New to SQL Server Programming
 Using String Functions and Aggregate Functions

Author  Topic 

AegelisX15
Starting Member

1 Post

Posted - 2014-03-07 : 19:04:45
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

38200 Posts

Posted - 2014-03-07 : 19:23:27
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

71 Posts

Posted - 2014-03-10 : 15:50:27
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
   

- Advertisement -