Jump to content

GROUP BY particular fields value??


Scooby08

Recommended Posts

If I have a table with info like so:

 

id    user_id    type    status    created_on

1      1            a          pending  2011-02-14 23:26:26

2      1            b          pending  2011-02-14 23:26:26

3      1            c          pending  2011-02-14 23:26:26

4      1            c          pending  2011-02-14 23:26:26

5      1            a          pending  2011-02-14 23:26:26

 

Would there be a way to count the total rows, while making the type 'c' values count as only one row? So really there would be only 4 rows counted here..

 

Is there something similar to the below out there that could work?

 

SELECT * FROM table WHERE status = 'pending' GROUP BY type = 'c'

 

Thanks!

Link to comment
Share on other sites

Hi,

 

first count the rows where type != 'c' (or if you want to more expects use "not in"), and after this method check whether type = 'c' row is exist or not...

(in one query i think it would more expensive)

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.