celfyn Posted September 12, 2007 Share Posted September 12, 2007 I have a stored procedure which returns a set of columns form different tables. Is it possible to use the distinct keyword on one of these columns? I have tried the following:SELECT distinct(ID_Staff), Pay_Number, First_Name ...It doesn't generate errors, but doesn't give me the result I want - it returns all the rows for the query.Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted September 12, 2007 Share Posted September 12, 2007 What results are you trying to get? It wouldn't make sense to use a function like distinct with the query returning the other columns in the database. It wouldn't make sense for a row to be:distinct(id); pay_number; first_nameThe id is already distinct because there's only one in the row. There aren't two IDs in the same row. Likewise, if you have three rows like this: id pay_number first_name-------------------------------1 10 Joe1 20 John1 30 James Which pay_number and first_name is it supposed to return with the record containing distinct ID 1? It doesn't make sense to use distinct in that context, so it might be legal to use distinct on any column but it's not going to do what you expect. I can't get from your question what you're trying to do though, or what you want to happen.But at least the column names aren't in Welsh.. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.