Solved

Select First value from Detail table

Posted on 2006-11-08
2
813 Views
Last Modified: 2008-01-09
Hi All,

          I am working on CustomerMaster & CustomerDetail tables. In Detail table, there are many records for one customerID and CustomerID is the PK in Master table . I want to create a SQL statement which should include all the records from Master Table and first matching record from the Detail Table.
How do we write a SQL sttement.?
Any help on this problem is appreciated.

Thanks in advance.
SMV



0
Comment
Question by:smv939
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 17901065
select *
from master m
join detail d
 on d.master_key = m.key
where d.somefield = ( select top 1 i.somefield from detail i where i.master_key = m.key )
0
 

Author Comment

by:smv939
ID: 17901320
Thanks so much. It worked.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question