Selecting distinct rows - oracle 9 sql

Posted on 2008-11-18
Medium Priority
Last Modified: 2013-12-19
Please see the attached which displays a) the current output and b) the desired output.

This data is looking at a questions and answers given in two electronic forms for two different clients. The question text appears in the QST_DESC column. Any answers given will appear in the AVD_DATA column. If an answer has been provided, the string DATA will appear in the ANV_NAME column.

I would like each question (and answer) row to only appear once for each client- so if the clients question has been answered I would like this row to appear (there will be the text DATA in the ANV_NAME column), if no answer has been provided the row will not have the word DATA in the ANV_NAME column and I would like this row to appear.

I hope this make some sort of sense!  Any help with this is appreciated.

Question by:tonMachine100
LVL 27

Accepted Solution

sujith80 earned 1200 total points
ID: 22983575
Try this (For 9i)
row_number() over(partition by FIRST_NAME, QST_QSE_ID order by ANV_NAME) rn
from <your table>
where rn = 1

Open in new window

LVL 22

Expert Comment

ID: 22983594
What key(s) exist in your table? When there is more than one answer for a question which one do you want to return? Do you want to pick one at random or should some rule be applied?

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
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.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

809 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