Solved

Select First value from Detail table

Posted on 2006-11-08
2
806 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 142

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
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…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now