Question Locked

How to select only a single data from many record?

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,
I 'm trying to select data from oracle database to excel. I faced difficulty to select one data for each id, where for one id, we got many row.
The other one is how to make sure that the id is selected from database match properly with the id that already in excel.
The connection between database and excel can establish, I think the sql statement should be changed. Anyone can help me with sql syntax? Any assistance would be greatly appreciated.

Thanks.

4 replies

by tony hopkinson

which one of the many you want.

The 'first' one would be
Select Top 1 * From MyTable Where MyID = ?

Or if there's some sort of ordering in there

Select Top 1 * From MyTable Where MyID = ? Order By SomeField

HtHs

by leynaixora

Thanks for your opinion. But it still not working. I need to select the first one data and make sure it match with the id already in excel.

by tony hopkinson

Your description suggested you were executing a query soemtheing like
Select * From Some SameTable Wher SomeID = [A1]

Where A1 is the id you want, but that that there is more than one record in teh table for that ID, therefore use Top or some such.

If it isn't the same id then obviously that isn't what you are doing

So if the id does n't match, what are you doing

This discussion is closed to new replies.