If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > sql logic and code question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-05-10, 05:34
nemrut nemrut is offline
Registered User
 
Join Date: Jul 2010
Posts: 2
sql logic and code question

here(image link) how my table is going to look like;

db screenshot on Flickr - Photo Sharing!

supposing i want to print a message tells who live in the same home

if their street and door numbers are the same.

ex:

ahmet,hakan,kaan(name) live at the same home
irem,semih live at the same home

how can i figure out the sql code here?
thx for your answers!
Reply With Quote
  #2 (permalink)  
Old 07-05-10, 05:53
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Code:
SELECT t.name
     , t.surname
     , t.street
     , t.door
  FROM ( SELECT street
              , door
           FROM daTable
         GROUP
             BY street
              , door
         HAVING COUNT(*) > 1 ) AS d
INNER
  JOIN daTable AS t
    ON t.street = d.street
   AND t.door   = d.door
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 07-06-10, 13:46
nemrut nemrut is offline
Registered User
 
Join Date: Jul 2010
Posts: 2
thank you very much. it works fine.

can we add an "id " cloumn which has same id inputs for same "street and door" s? so that i can say same id's live at same place.

it's ok if you suggest another way, thx again
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On