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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 someone help me how to use as

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 as
2.show name employee, department number and the manager of employee id which is located in the city of seattle, using as

table
from employees

employee_id first_name departemen_id
200 jennifer 10

from department

department_id department_name manager id location
10 Administration 200 1700


from location

locatin_id city
1700 seattle

hi 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.aspx

quote:

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]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-10-14 : 01:45:04
The post doesnt seem to related to the use of alias

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

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
Go to Top of Page

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]
Go to Top of Page

Ifor
Aged Yak Warrior

700 Posts

Posted - 2009-10-15 : 07:08:02
http://www.w3schools.com/sql/default.asp
Go to Top of Page

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 me

hi pliss teach me sql
Go to Top of Page

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%'
Go to Top of Page

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 id
which is located in the city of seattle, table below,
excuse me a lot to ask, but I really do not understand please help me

hi pliss teach me sql
Go to Top of Page

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 this

SELECT Fname as first_name
FROM EMP as employees
WHERE Fname like 'a%'

hi pliss teach me sql
Go to Top of Page

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
Go to Top of Page

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_id
FROM location
WHERE City='seattle'





hi pliss teach me sql
Go to Top of Page

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_id
FROM location
WHERE City='seattle'





hi pliss teach me sql


Can you clearly tell us what do you want to do with alias name?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

demonicius
Starting Member

10 Posts

Posted - 2009-10-15 : 08:56:56
this is homework from school

hi pliss teach me sql
Go to Top of Page

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.
Go to Top of Page

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.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -