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
 cant get the result :-S please help me

Author  Topic 

jasmin
Starting Member

1 Post

Posted - 2008-07-28 : 09:49:21
Hi there!

I am new on SQL. I have been training on for a month. I have given a question by my boss to test me. Could you please help me for this? There is a table like below,

Eleman_Id Eleman_Ad Mudur_Id
5 Faruk SARI 20
10 Selma ACAR 35
15 Ali KUCUK 35
20 Mehmet CICEK 45
25 Fatma FIRAT 20
30 Ahmet AK 20
35 Emine GUVEN 45
40 Salim GUVEN 20
45 Veli INCE
50 Ayse OZ 35

I need to get the below result

Mudur AD Eleman_Ad
Emine GUVEN Selma ACAR
Emine GUVEN Ali KUCUK
Emine GUVEN Ayse OZ
Mehmet CICEK Faruk SARI
Mehmet CICEK Fatma FIRAT
Mehmet CICEK Ahmet AK
Mehmet CICEK Salim GUVEN
Veli INCE Mehmet CICEK
Veli INCE Emine GUVEN
YOK Veli INCE

thanks in advance

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-07-28 : 09:51:46
you need to write the query so it joins the table to itself on eleman_id = mudur_id

show us what you tried so far

Em
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-28 : 09:59:22
quote:
Originally posted by jasmin

Hi there!

I am new on SQL. I have been training on for a month. I have given a question by my boss to test me. Could you please help me for this? There is a table like below,

Eleman_Id Eleman_Ad Mudur_Id
5 Faruk SARI 20
10 Selma ACAR 35
15 Ali KUCUK 35
20 Mehmet CICEK 45
25 Fatma FIRAT 20
30 Ahmet AK 20
35 Emine GUVEN 45
40 Salim GUVEN 20
45 Veli INCE
50 Ayse OZ 35

I need to get the below result

Mudur AD Eleman_Ad
Emine GUVEN Selma ACAR
Emine GUVEN Ali KUCUK
Emine GUVEN Ayse OZ
Mehmet CICEK Faruk SARI
Mehmet CICEK Fatma FIRAT
Mehmet CICEK Ahmet AK
Mehmet CICEK Salim GUVEN
Veli INCE Mehmet CICEK
Veli INCE Emine GUVEN
YOK Veli INCE

thanks in advance




the clue is you should take a self join i.e join your table with itself to retrive the expected result. the relationship is defined by column Eleman_Id & Mudur_Id. Now try it and post back if you face any problems.
Go to Top of Page
   

- Advertisement -