Query Help - Denormalized Table

# Thread: Query Help - Denormalized Table

1. Senior Member
Join Date
Dec 1969
Posts
1,203

## Query Help - Denormalized Table

Let&#039;s say I have a table in Oracle that looks like this:<BR><BR>Field1&nbsp;&#124Field2&nbsp;&nbsp;&# 124Field3<BR>-------------------------<BR>1234&nbsp;&nbsp;&#124bob&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&#124 11010<BR>1235&nbsp;&nbsp;&#124bob&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&#124 11010<BR>1236&nbsp;&nbsp;&#124bob&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&#124 11010<BR>2143&nbsp;&nbsp;&#124boo&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&#12400111<BR>2145&nbsp;&nbsp;&#124bo o&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#12400111<BR><BR>P lainly, this is an example of a table that has been denormalized. The first three records are in every way identical, except for the last digit of their ID (the value in Field1). The last two records are identical to each other (again, except for the last digit of their ID).<BR><BR>I have a table whose data looks like this. It&#039;s not a table of my design, but of my client&#039;s design.<BR><BR>I need to query this table and get the following results:<BR><BR>Field1&nbsp;&#124Field2&nbsp;&nbsp ;&#124Field3<BR>-------------------------<BR>1234&nbsp;&nbsp;&#124bob&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&#124 11010<BR>2143&nbsp;&nbsp;&#124boo&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&#12400111<BR><BR>Basically, the result I need is something like a normalized version of the original table - get the first row of results for each set of "almost identical" rows.<BR><BR>I&#039;m already able to return something like this (with the last digit in the ID chopped off), but that still isn&#039;t exactly what I need:<BR>Field1&nbsp;&#124Field2&nbsp;&nbsp;&#124F ield3<BR>-------------------------<BR>123&nbsp;&nbsp;&nbsp;&#124bob&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&#124 11010<BR>214&nbsp;&nbsp;&nbsp;&#124boo&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&#12400111<BR><BR>Remember - this is in Oracle... Any thoughts or suggestions would be really appreciated...<BR><BR>kurt

2. Senior Member
Join Date
Dec 1969
Posts
1,203

## dunno how the ?'s got in there

I previewed my post - no question marks in the table illustrations. In the posted version, question marks.<BR><BR>Anyway, disregard the quesiton marks and imagine that each record with an ID starting with 214 has the value 01110 in Field3.<BR><BR>Sorry... Weird stuff...

3. Senior Member
Join Date
Dec 1969
Posts
2,437

## RE: Query Help - Denormalized Table

select min(field1),field2,field3<BR> from t<BR> group by field2,field3

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•