| Author |
Topic |
|
demonicius
Starting Member
10 Posts |
Posted - 2009-10-14 : 00:02:26
|
| hi guys i am newbie, pliss help me, i have some question,1.show employee names and department names of his first name beginning with the letter a (empolyees name and departement)using as2.show name employee, department number and the manager of employee id which is located in the city of seattle, using astable from employeesemployee_id first_name departemen_id200 jennifer 10from departmentdepartment_id department_name manager id location10 Administration 200 1700from location locatin_id city1700 seattlehi pliss teach me sql |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-10-14 : 00:12:22
|
refer to http://msdn.microsoft.com/en-us/library/ms176104%28SQL.90%29.aspxquote: column_ alias Is an alternative name to replace the column name in the query result set. For example, an alias such as Quantity, or Quantity to Date, or Qty can be specified for a column named quantity. Aliases are used also to specify names for the results of expressions, for example: USE AdventureWorks; GO SELECT AVG(UnitPrice) AS 'Average Price' FROM Sales.SalesOrderDetail; column_alias can be used in an ORDER BY clause. However, it cannot be used in a WHERE, GROUP BY, or HAVING clause. If the query expression is part of a DECLARE CURSOR statement, column_alias cannot be used in the FOR UPDATE clause.
KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-14 : 01:45:04
|
| The post doesnt seem to related to the use of aliasMadhivananFailing to plan is Planning to fail |
 |
|
|
demonicius
Starting Member
10 Posts |
Posted - 2009-10-15 : 06:54:39
|
| so , i have question again, What syntax or command is used when we want to display the names of the start with the letter a?hi pliss teach me sql |
 |
|
|
YellowBug
Aged Yak Warrior
616 Posts |
Posted - 2009-10-15 : 07:00:50
|
| [code]SELECT first_name FROM employees WHERE first_name like 'a%'[/code] |
 |
|
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2009-10-15 : 07:08:02
|
| http://www.w3schools.com/sql/default.asp |
 |
|
|
demonicius
Starting Member
10 Posts |
Posted - 2009-10-15 : 07:30:53
|
| owh tq yellow bug, n i have question again, if i am using as (alias) so where I had to put?, pliss help mehi pliss teach me sql |
 |
|
|
YellowBug
Aged Yak Warrior
616 Posts |
Posted - 2009-10-15 : 07:38:17
|
| You can alias the table name and/or the column name:SELECT fname = first_name FROM employees emp WHERE first_name like 'a%' |
 |
|
|
demonicius
Starting Member
10 Posts |
Posted - 2009-10-15 : 07:43:29
|
| I understand, so how about no 2, show name employee, department number and the manager of employee idwhich is located in the city of seattle, table below,excuse me a lot to ask, but I really do not understand please help mehi pliss teach me sql |
 |
|
|
demonicius
Starting Member
10 Posts |
Posted - 2009-10-15 : 07:53:11
|
quote: Originally posted by YellowBug You can alias the table name and/or the column name:SELECT fname = first_name FROM employees emp WHERE first_name like 'a%'
if I can write it like thisSELECT Fname as first_nameFROM EMP as employeesWHERE Fname like 'a%'hi pliss teach me sql |
 |
|
|
rocknpop
Posting Yak Master
201 Posts |
Posted - 2009-10-15 : 08:11:38
|
| yes you can and you should go through the link provided by Ifor--------------------Rock n Roll with SQL |
 |
|
|
demonicius
Starting Member
10 Posts |
Posted - 2009-10-15 : 08:36:35
|
| how about this one, please change by using alias SELECT first_name,department_id,manager_idFROM locationWHERE City='seattle' hi pliss teach me sql |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-15 : 08:53:06
|
quote: Originally posted by demonicius how about this one, please change by using alias SELECT first_name,department_id,manager_idFROM locationWHERE City='seattle' hi pliss teach me sql
Can you clearly tell us what do you want to do with alias name?MadhivananFailing to plan is Planning to fail |
 |
|
|
demonicius
Starting Member
10 Posts |
Posted - 2009-10-15 : 08:56:56
|
| this is homework from schoolhi pliss teach me sql |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-15 : 09:54:03
|
Your signature should be:hi pliss teach me how to ask questions No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2009-10-15 : 14:29:27
|
| simply follow ALL the links in my sig, and you will be fine.http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
|