Click here to Skip to main content
15,897,519 members
Home / Discussions / Database
   

Database

 
GeneralSelect statments problems Pin
Member 17338781-Apr-05 0:09
Member 17338781-Apr-05 0:09 
GeneralRe: Select statments problems Pin
Colin Angus Mackay1-Apr-05 0:22
Colin Angus Mackay1-Apr-05 0:22 
GeneralRe: Select statments problems Pin
Michael Potter1-Apr-05 4:34
Michael Potter1-Apr-05 4:34 
GeneralRe: Select statments problems Pin
Yulianto.1-Apr-05 17:17
Yulianto.1-Apr-05 17:17 
QuestionAm I missing a header file? Pin
IlanTal31-Mar-05 23:31
IlanTal31-Mar-05 23:31 
AnswerRe: Am I missing a header file? Pin
Colin Angus Mackay1-Apr-05 7:37
Colin Angus Mackay1-Apr-05 7:37 
QuestionHow do I COMMIT an oracle temp table thru ado.net Pin
phil.short31-Mar-05 10:50
phil.short31-Mar-05 10:50 
GeneralSQL challenge Pin
Chris Losinger31-Mar-05 4:04
professionalChris Losinger31-Mar-05 4:04 
i have a table with 8 columns. the first seven columns form a key.

i need to select 7 of them, and join another table :

SELECT mt.c1, mt.c2, mt.c3, mt.v4, mt.c5, mt.c6, mt.c7, ot.ot5 MyTable mt
LEFT OUTER JOIN OtherTable ot ON
mt.c1 = ot.ot1
mt.c2 = ot.ot2
mt.c3 = ot.ot3
mt.c4 = ot.ot4
WHERE mt.c1=0

i'll get something like this:
c1 c2 c3 c4 c5 c6 c7 ot5
------------------------
 1  1  1  1  1  1  1  91
 1  1  1  1  1  1  2  92
 1  1  1  1  1  2  1  93
 1  1  1  1  1  3  1  94

simple so far.

since the the key to MyTable is composed of 7 columns, it's possible (and likely) that for any given row, the first 6 of those columns will match the first 6 from some other row (and that's why the key is composed of 7 columns, obviously). ex., see the first and second rows in my little result set.

but, i need to get rows such that the first 6 columns in any row will be unqiue in the result set. in other words, if two or more rows match in the first 6 columns, i need to discard all but the first (or all but the last, it doesn't matter, as long as there is only one):
c1 c2 c3 c4 c5 c6 c7 ot5
------------------------
 1  1  1  1  1  1  1  91
 1  1  1  1  1  1  2  92  <---- eliminate this row
 1  1  1  1  1  2  1  93
 1  1  1  1  1  3  1  94


so, is there a way to do this?

GROUP BY won't do it. DISTINCT doesn't help.


Image Toolkits | Image Processing | Cleek

GeneralRe: SQL challenge Pin
Colin Angus Mackay31-Mar-05 4:18
Colin Angus Mackay31-Mar-05 4:18 
GeneralRe: SQL challenge Pin
Chris Losinger31-Mar-05 5:15
professionalChris Losinger31-Mar-05 5:15 
Questionparameterized queries? Pin
IlanTal31-Mar-05 3:31
IlanTal31-Mar-05 3:31 
AnswerRe: parameterized queries? Pin
IlanTal31-Mar-05 18:38
IlanTal31-Mar-05 18:38 
GeneralReading BLOB data from database Pin
Member 165844231-Mar-05 1:37
Member 165844231-Mar-05 1:37 
GeneralRe: Reading BLOB data from database Pin
Member 165844211-Apr-05 2:57
Member 165844211-Apr-05 2:57 
QuestionReporting Service - bug with drilldown? Pin
devvvy30-Mar-05 23:56
devvvy30-Mar-05 23:56 
GeneralNHibernate Child-Parent relationship -- Key happens to be a composite key Pin
devvvy29-Mar-05 23:23
devvvy29-Mar-05 23:23 
GeneralPackage and deployment Pin
Salman Sheikh29-Mar-05 19:00
Salman Sheikh29-Mar-05 19:00 
GeneralLaunching SQL Server job xp_cmdshell Pin
devvvy29-Mar-05 17:32
devvvy29-Mar-05 17:32 
GeneralOracleClient and Timestamp datatype Pin
Yos Nugroho29-Mar-05 17:21
Yos Nugroho29-Mar-05 17:21 
GeneralGUIDs as PK's Pin
Marc Clifton29-Mar-05 10:04
mvaMarc Clifton29-Mar-05 10:04 
GeneralRe: GUIDs as PK's Pin
rwestgraham29-Mar-05 10:25
rwestgraham29-Mar-05 10:25 
GeneralRe: GUIDs as PK's Pin
Carl Mercier1-Apr-05 10:24
Carl Mercier1-Apr-05 10:24 
GeneralRe: GUIDs as PK's Pin
Marc Clifton4-Apr-05 5:16
mvaMarc Clifton4-Apr-05 5:16 
GeneralRe: GUIDs as PK's Pin
Andy Brummer29-Mar-05 11:14
sitebuilderAndy Brummer29-Mar-05 11:14 
GeneralRe: GUIDs as PK's Pin
turbochimp29-Mar-05 19:19
turbochimp29-Mar-05 19:19 

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.