|
I have a table that's basically a log of searches that has a userid, the search, and the timestamp as the columns. I'm trying to run a query that gets a users last few unique searches. Let's say I have a table like:code:
code:
What I actually get is you and bar. I suspect that the last foo is cut out of the results because the DISTINCT clause matches it with the first foo and eliminates it before the ORDER BY is ever applied. Is there some way to get around this?
|
# ¿ Dec 8, 2007 05:15 |
|
|
# ¿ May 7, 2024 13:37 |
|
Sorry guys I thought I replied, but apparently not. I seem to have solved it by running this:code:
|
# ¿ Dec 9, 2007 17:20 |
|
I have a fun little query that I wanted to write, and I thought it would be really simple, but turns out that it may actually be impossible to do in one query. I wanted to get your guys' ideas about what may be the best way of doing this. I have two tables. One is a table of items. The other is a table of attributes, with multiple possible attributes of several attribute types possible for each item. So I have something like this: code:
I've been trying different group by and count combinations, but at this point I'm ready to give up and just give each tag type its own table. Is there a way of just making this one query or should I just separate the tag types into their own tables?
|
# ¿ Jan 24, 2008 23:12 |
|
Rumsfoord posted:SELECT Count(attributes.item_id) AS item_attribute_type_count, attributes.tag_type, attributes.item_id The problem with doing this is that if you join on the items table (which you need to do in order to get the rest of the info about that item), this will return one row for each type of attribute, so each item will be returned several times.
|
# ¿ Jan 25, 2008 04:17 |