Click here to Skip to main content
15,895,084 members
Home / Discussions / Database
   

Database

 
Questionget into big problem-need help Pin
aligatojohn1-Jul-06 0:10
aligatojohn1-Jul-06 0:10 
AnswerRe: get into big problem-need help Pin
Colin Angus Mackay1-Jul-06 1:21
Colin Angus Mackay1-Jul-06 1:21 
GeneralRe: get into big problem-need help Pin
aligatojohn1-Jul-06 18:51
aligatojohn1-Jul-06 18:51 
GeneralRe: get into big problem-need help Pin
Colin Angus Mackay1-Jul-06 23:05
Colin Angus Mackay1-Jul-06 23:05 
GeneralRe: get into big problem-need help Pin
aligatojohn2-Jul-06 1:32
aligatojohn2-Jul-06 1:32 
GeneralRe: get into big problem-need help Pin
Colin Angus Mackay2-Jul-06 1:42
Colin Angus Mackay2-Jul-06 1:42 
GeneralRe: get into big problem-need help Pin
aligatojohn3-Jul-06 0:16
aligatojohn3-Jul-06 0:16 
GeneralRe: get into big problem-need help Pin
Colin Angus Mackay3-Jul-06 1:51
Colin Angus Mackay3-Jul-06 1:51 
I see now. You need to aggregate the rows in table2 somehow then join it. However there is no natural aggregation that you can use. From your example result set you appear to be taking the lowest id for each type - so that is the colum that needs to be aggregated.

This is the aggregation component:
SELECT MIN(id) AS id, type
FROM table2
GROUP BY type
It basically takes the first row for each type and discards the rest.

Now it has to be joined up. The result of the aggregation is added to the previous join to act as a filter.
SELECT table1.type, table1.name, table2.content, table2.shortDesc
FROM table1
INNER JOIN table2 ON table1.type = table2.type
INNER JOIN (SELECT MIN(id) AS id, type
            FROM table2
            GROUP BY type) AS filterQuery ON filterQuery.id = table2.id
This should now produce the results that you want.


Scottish Developers events:
* .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy
* Developer Day Scotland: are you interested in speaking or attending?

My: Website | Blog
GeneralRe: get into big problem-need help Pin
aligatojohn3-Jul-06 20:49
aligatojohn3-Jul-06 20:49 
QuestionHow 2 find 4th working day of any month using PL/SQL? Pin
Jazzy_J30-Jun-06 23:55
Jazzy_J30-Jun-06 23:55 
AnswerRe: How 2 find 4th working day of any month using PL/SQL? Pin
Paul Conrad1-Jul-06 17:53
professionalPaul Conrad1-Jul-06 17:53 
QuestionGetting Data from Excel to SQL Server.. Pin
GBal30-Jun-06 23:33
GBal30-Jun-06 23:33 
QuestionPlease Help me for finding a word from field in SQL Pin
Jesal Rana30-Jun-06 19:32
Jesal Rana30-Jun-06 19:32 
AnswerRe: Please Help me for finding a word from field in SQL Pin
Paul Conrad30-Jun-06 19:52
professionalPaul Conrad30-Jun-06 19:52 
QuestionCLR Integration and SQL Express XCOPY deployment hell Pin
Furty30-Jun-06 16:23
Furty30-Jun-06 16:23 
QuestionCreate composite key on existing table Pin
leckey30-Jun-06 9:27
leckey30-Jun-06 9:27 
AnswerRe: Create composite key on existing table Pin
Colin Angus Mackay30-Jun-06 10:22
Colin Angus Mackay30-Jun-06 10:22 
GeneralRe: Create composite key on existing table Pin
leckey30-Jun-06 10:31
leckey30-Jun-06 10:31 
QuestionIBM DB2 SQL Error Code to String Pin
Christopher Stratmann30-Jun-06 2:55
Christopher Stratmann30-Jun-06 2:55 
QuestionLaoding the whole database tables into a DataSet Pin
hamidreza_buddy30-Jun-06 0:43
hamidreza_buddy30-Jun-06 0:43 
AnswerRe: Laoding the whole database tables into a DataSet [modified] Pin
Colin Angus Mackay30-Jun-06 1:02
Colin Angus Mackay30-Jun-06 1:02 
GeneralRe: Laoding the whole database tables into a DataSet Pin
hamidreza_buddy1-Jul-06 0:53
hamidreza_buddy1-Jul-06 0:53 
GeneralRe: Laoding the whole database tables into a DataSet Pin
Colin Angus Mackay1-Jul-06 1:15
Colin Angus Mackay1-Jul-06 1:15 
QuestionPlease help me for finding a word from a field of database Pin
Jesal Rana29-Jun-06 23:22
Jesal Rana29-Jun-06 23:22 
AnswerRe: Please help me for finding a word from a field of database Pin
Paddy Boyd29-Jun-06 23:35
Paddy Boyd29-Jun-06 23:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.