SQL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a report that feeds from a query - When I run the report, I want the
last names in alphabetical order. Below is the SQL for the query. If you
notice, at the end it states - ORDER BY LastName; - Why aren't the last names
in order? Do I have to do something to the report?
Thank you

SELECT [LastName] & ", " & [FirstName] AS Employee, EmployeeID, Home, Cell,
Emergency, Contact, Relationship
FROM tblDepartment INNER JOIN qryEmployeeActive ON
tblDepartment.DeptID=qryEmployeeActive.DepartmentID
WHERE ((tblDepartment.DeptID)=[Please Enter Department Number])
ORDER BY LastName;
 
The order of records in a report is defined by the Sorting And Grouping
dialog (View menu in report design view.)

In most cases, therefore it is a waste of effort to use an ORDER BY in your
query as well.
 
I'm sorry

Brian Bastl said:
too lazy to rant. Look here:
http://home.att.net/~california.db/tips.html#aTip10

Brian


Karen said:
I have a report that feeds from a query - When I run the report, I want the
last names in alphabetical order. Below is the SQL for the query. If you
notice, at the end it states - ORDER BY LastName; - Why aren't the last names
in order? Do I have to do something to the report?
Thank you

SELECT [LastName] & ", " & [FirstName] AS Employee, EmployeeID, Home, Cell,
Emergency, Contact, Relationship
FROM tblDepartment INNER JOIN qryEmployeeActive ON
tblDepartment.DeptID=qryEmployeeActive.DepartmentID
WHERE ((tblDepartment.DeptID)=[Please Enter Department Number])
ORDER BY LastName;
 
Thank you - It works great!

Allen Browne said:
The order of records in a report is defined by the Sorting And Grouping
dialog (View menu in report design view.)

In most cases, therefore it is a waste of effort to use an ORDER BY in your
query as well.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Karen said:
I have a report that feeds from a query - When I run the report, I want the
last names in alphabetical order. Below is the SQL for the query. If you
notice, at the end it states - ORDER BY LastName; - Why aren't the last
names
in order? Do I have to do something to the report?
Thank you

SELECT [LastName] & ", " & [FirstName] AS Employee, EmployeeID, Home,
Cell,
Emergency, Contact, Relationship
FROM tblDepartment INNER JOIN qryEmployeeActive ON
tblDepartment.DeptID=qryEmployeeActive.DepartmentID
WHERE ((tblDepartment.DeptID)=[Please Enter Department Number])
ORDER BY LastName;
 
Back
Top