Jump to content

Do something different if more than one consecutively?


sciencebear

Recommended Posts

I'm running a query that grabs all the info from several rows of a table called updates. Updates has a column called "type,"  among other columns. For simplicity, we'll say the types are a, b, c, d, and e. There is also another column, user, which says which user is attached to which update. The query takes each row in order from most recent to least. It works great. However, I want to do something different if there are more than one of a specific type from a certain user in a row. Like this

 

type user

a      1

b      2

c      1

c      1

d    1

d    2

e    1

 

I would like to instead of showing:

 

"1 did a"

"2 did b"

"1 did c"

"1 did c"

"1 did d"

"2 did d"

"1 did e"

 

Show something like this:

 

"1 did a"

"2 did b"

"1 did c twice"

"1 did d"

"2 did d"

"1 did e"

 

Any suggestions?

 

Sorry if I'm not making a lot of sense. If you have questions, I can try to answer them.

 

 

Link to comment
Share on other sites

Doesn't count count all the elements though? Perhaps I was not being specific enough. I only want to do something different if there are more than one consecutively, so if there was another instance at a different time I don't want to change it.

 

If there's not a plausible way to do that, all the entries have time stamps attached to them. I could settle for doing something different if the time stamps are with a certain amount of time, even if not consecutive, but I don't know how I'd do that either.

Link to comment
Share on other sites

Doesn't count count all the elements though? Perhaps I was not being specific enough. I only want to do something different if there are more than one consecutively, so if there was another instance at a different time I don't want to change it.

 

If there's not a plausible way to do that, all the entries have time stamps attached to them. I could settle for doing something different if the time stamps are with a certain amount of time, even if not consecutive, but I don't know how I'd do that either.

 

Have you tried jl's recommendation?

Link to comment
Share on other sites

Have you tried jl's recommendation?

 

I'm trying it right now. Unfortunately, that only results in a row for each different type once, and gives a user along with the total count for that type for every user. I'm not sure how I would implement that to do what I need.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.