Jump to content

Calling SQL experts: count and group by


Recommended Posts

Posted

Oka table lo 

name , site, channel, posts

scrooge, afdb, discussion, 100

scrooge,afdb, visa, 10

scrooge, ttdb, discussion, 100

spartan, afdb, discussion. 200

spartan, afdb, masala, 3000

spartan, ILDB, relationship, 10000

samaja, afdb, masala, 100

loser, afdb, masala, 10000

loser, afdb, discussion, 100

 

undi... i want output as in how many distinct channels scrooge participated(afdb and ttdb) 

 

name , site

scrooge, 2

spartan, 2

samaja, 1

loser, 1

 

emi cheyyali

Posted

no.of distinct channels aithe idi anukulu ...

select name, count(distinct channel)

from table

group by name

 

Posted

no.of distinct sites for each person aithe idi...

select name, count(distinct site)

from table

group by name

Posted
38 minutes ago, k2s said:

Oka table lo 

name , site, channel, posts

scrooge, afdb, discussion, 100

scrooge,afdb, visa, 10

scrooge, ttdb, discussion, 100

spartan, afdb, discussion. 200

spartan, afdb, masala, 3000

spartan, ILDB, relationship, 10000

samaja, afdb, masala, 100

loser, afdb, masala, 10000

loser, afdb, discussion, 100

 

undi... i want output as in how many distinct channels scrooge participated(afdb and ttdb) 

 

name , site

scrooge, 2

spartan, 2

samaja, 1

loser, 1

 

emi cheyyali

thatha nee explanation wrong.

 

afdb,ttdb are not channels they are sites.

 

Ika Answer antava paina @Prince_Fan vuncle ichadu choodu... valla Christian roommate confirm chesadu (vuncle eeroje talantu posadanta) photo-thumb-55678.jpg

 

Posted

@k2s

Select name, count(Distinct site)

as "number of sites"

from <tablename>

Posted
37 minutes ago, Prince_Fan said:

no.of distinct channels aithe idi anukulu ...

select name, count(distinct channel)

from table

group by name

 

thanks lolbob... adey chesa... 

naaku number of distinct channels for distinct names kavali.... so i used 

select distinct name, count(distinct channel) 

ani use chesa.. 

Posted
13 minutes ago, Bhai said:

thatha nee explanation wrong.

 

afdb,ttdb are not channels they are sites.

 

Ika Answer antava paina @Prince_Fan vuncle ichadu choodu... valla Christian roommate confirm chesadu (vuncle eeroje talantu posadanta) photo-thumb-55678.jpg

 

lolbob ki ardam ayindi.. answer seppadu. madyalo nuvvu thappulu vethaku..... naaku query execute ayindi with result 20 mins back ee 

Posted
7 minutes ago, Spartan said:

@k2s

Select name, count(Distinct site)

as "number of sites"

from <tablename>

select distinct name, count(distinct site) 

name kuda distinct kavali uncle.. 

Posted
Just now, mysterious said:

select name, count(distinct(site)) from tablename where name='scoorge';

gappudu scrooge okka row ki answer osthadi... emo 

Posted

the above ans is according to your question and if you are looking for total count for scoorge

Posted
2 minutes ago, mysterious said:

the above ans is according to your question and if you are looking for total count for scoorge

i want for all users man.. like this

name , site

scrooge, 2

spartan, 2

samaja, 1

loser, 1

 

Image result for brahmi gifs

Posted
  1. select name, site, count( *) from k2s group by name, site;
     
  2. samaja    afdb    1
    loser    afdb    2
    scrooge    ttdb    1
    spartan    afdb    2
    scrooge    afdb    2

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.   Paste as plain text instead

  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...