/    Sign up×
Community /Pin to ProfileBookmark

Need Help With Select Statement

I’ve got a select statement that I know is wrong, but don’t know how to fix it. What I want to do is show the first record in the table for each different value in the UID field. Here’s a sample table with the ones I don’t want to show in bold. The current incorrect select statement is below the sample table. Any help would be greatly appreciated. Thanks!

[U]UID ———- LoginID[/U]
1000 ———- 1
1005 ———- 2
1010 ———- 3
1015 ———- 4
1100 ———- 5
[B]1000[/B] ——— 6
1120 ———- 7
[B]1015[/B] ——— 8

[code]
SELECT DISTINCT(UID), LoginID FROM tblPURLHits ORDER BY LoginID
[/code]

to post a comment

7 Comments(s)

Copy linkTweet thisAlerts:
@russellMay 31.2006 — SELECT uid, min(LogInId) as LogInId

FROM TableName

GROUP BY uid

ORDER BY LoginId
Copy linkTweet thisAlerts:
@nbcrockettauthorJun 02.2006 — Thanks for the response, but unfortunitely it didn't work. It might be because I'm using the select statement in asp code to pull a recordset from an access database. Any other ideas?
Copy linkTweet thisAlerts:
@russellJun 02.2006 — what happened when you did it?
Copy linkTweet thisAlerts:
@nbcrockettauthorJun 02.2006 — Nothing, the asp page timed out. It should have returned the results within a few seconds if it had made a connection with the table it was pulling the data from. Everytime I've gotten this type of problem in the past the error was one of two things. It was either the select statement wasn't compatible or it was trying to display to many records. In this case I tested the code to see where it started having problems and found that the issue was the select statement. Hope that answers your question.
Copy linkTweet thisAlerts:
@russellJun 02.2006 — did you change "tableName" here

SELECT uid, min(LogInId) as LogInId

FROM [b]TableName[/b]

GROUP BY uid

ORDER BY LoginId

to your real table name?
Copy linkTweet thisAlerts:
@nbcrockettauthorJun 02.2006 — Yes, I made sure all aspects of the select statement coincided with my database. ?
Copy linkTweet thisAlerts:
@russellJun 02.2006 — what db are u using? is the table properly indexed? how many records total in the table? is it set to be case sensitive? let's see the code...
×

Success!

Help @nbcrockett spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...