Re: [sqlalchemy] Re: Select * but apply distinct to one column

2016-03-09 Thread Jonathan Vanasco
If that ID is the primary key, then don't bother with a DISTINCT(). Just select everything from the table. Otherwise you're going to make the backend select everything , then waste time doing the distinct. A quick way to confirm would be to just run these 2 commands: SELECT

Re: [sqlalchemy] Re: Select * but apply distinct to one column

2016-03-09 Thread Alex Hall
That makes sense. Part of my problem is that, as I've mentioned in the past, I was recently hired. I didn't set anything up, and I still don't know for sure what I can trust to be unique, or 6 versus 8 characters, or a lot of other small details. That said, SSMS shows the item ID as a primary key,

Re: [sqlalchemy] Re: Select * but apply distinct to one column

2016-03-09 Thread Jonathan Vanasco
On Wednesday, March 9, 2016 at 3:02:05 PM UTC-5, Alex Hall wrote: > > Fair enough, thanks. I didn't realize it was such a complex task; I > figured it was just a matter of passing an argument to distinct() or > something equally easy. > Yeah PostgreSQL is the only db that supports "DISTINCT

Re: [sqlalchemy] Re: Select * but apply distinct to one column

2016-03-09 Thread Alex Hall
Fair enough, thanks. I didn't realize it was such a complex task; I figured it was just a matter of passing an argument to distinct() or something equally easy. Speed isn't a huge concern, so I suppose I could get around this by storing the item numbers I find and then checking that the row I'm

[sqlalchemy] Re: Select * but apply distinct to one column

2016-03-09 Thread Jonathan Vanasco
It would probably be best for you to figure out the correct raw sql you want, then convert it to SqlAlchemy. Postgres is the only DB I know of that offers "DISTINCT ON (columns)" -- and even that works a bit awkward. The query that you want to do isn't actually simple -- there are concerns