Jump to content

union all


tuzojazz

Recommended Posts

HiI have two tables: Employees_Norway and Employees_USAEmployees_Norway:Employee_ID E_Name-------------------------------01 Hansen, Ola 02 Svendson, Tove 03 Svendson, Stephen 04 Pettersen, Kari Employees_USA:Employee_ID E_Name------------------------------01 Turner, Sally 02 Kent, Clark 03 Svendson, Stephen 04 Scott, Stephen In order to list all employees in Norway and USA I'm using this query:------------------------------------------------SELECT E_Name FROM Employees_NorwayUNION ALLSELECT E_Name FROM Employees_USA------------------------------------------------I get this resultName ----------------------Hansen, Ola Svendson, Tove Svendson, Stephen Pettersen, Kari Turner, Sally Kent, Clark Svendson, Stephen Scott, Stephen What more does need my query to get the result in alphabetical order?Thanks!!

Link to comment
Share on other sites

In order to list all employees in Norway and USA I'm using this query:------------------------------------------------SELECT E_Name FROM Employees_NorwayUNION ALLSELECT E_Name FROM Employees_USA------------------------------------------------I get this resultName ----------------------Hansen, Ola Svendson, Tove Svendson, Stephen Pettersen, Kari Turner, Sally Kent, Clark Svendson, Stephen Scott, Stephen Thanks!!

Try thisSelect *From (SELECT E_Name FROM Employees_Norway UNION ALL SELECT E_Name FROM Employees_USA) Table_AliasOrder By E_Name
Link to comment
Share on other sites

Guest raman
HiI have two tables: Employees_Norway and Employees_USAEmployees_Norway:Employee_ID  E_Name-------------------------------01  Hansen, Ola 02  Svendson, Tove 03  Svendson, Stephen 04  Pettersen, Kari Employees_USA:Employee_ID  E_Name------------------------------01  Turner, Sally 02  Kent, Clark 03  Svendson, Stephen 04  Scott, Stephen In order to list all employees in Norway and USA I'm using this query:------------------------------------------------SELECT E_Name FROM Employees_NorwayUNION ALLSELECT E_Name FROM Employees_USA------------------------------------------------I get this resultName ----------------------Hansen, Ola Svendson, Tove Svendson, Stephen Pettersen, Kari Turner, Sally Kent, Clark Svendson, Stephen Scott, Stephen What more does need my query to get the result in alphabetical order?Thanks!!

It should be SELECT E_Name FROM Employees_NorwayUNION ALLSELECT E_Name FROM Employees_USA order by e_name asc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...