Jump to content

Sql Groupby Multiple Columns(Sub Grouping) Help Plz


Recommended Posts

Posted

Final ga try this.

 

SELECT transactiondate, Category,   COUNT(*) as count
FROM Table
GROUP BY transactiondate, Category
HAVING COUNT(*) > 1
ORDER BY COUNT(*) DESC

small change 

 

SELECT transactiondate, Category,   COUNT(*) as count
FROM Table
GROUP BY transactiondate, Category
HAVING COUNT(*) >= 1
ORDER BY COUNT(*) DESC

  • Replies 46
  • Created
  • Last Reply

Top Posters In This Topic

  • Silver_mani

    11

  • ParmQ

    10

  • dotnetrockz

    8

  • dkchinnari

    4

Top Posters In This Topic

Posted

intaki em db uncle....Oracle lo ayithe should work....is it mysql or sqlserver?

 

even mysql and sqlserver should work....

 

"count(*) as count" ani add cheyi

 

SELECT TRANSACTIONDATE,

CATEGORY,

COUNT(*) as count

FROM TABLE

GROUP BY  TRANSACTIONDATE,  CATEGORY

Posted

pls stop coming to DB..thanks for ur support  and understanding...

 

work aitadi vayya

Posted

work aitadi vayya

nee db future dpends on nissan :3D_Smiles_38:  :3D_Smiles_38:

Posted

pls stop coming to DB..thanks for ur support  and understanding...

 

uncle already promised earlier also. Nandita and Alia Bhatt ki voting petti, Alia ki okka vote ekkuva vacchina...DB ki raanu ani sapadham chesadu. @3$% @3$%

Posted

nee db future dpends on nissan  

 

Manodu ekkado tappu chesadu Query lo  ...

Posted

ur query's are working fine for that data...

 

may be issue is with my data retrieval rather than group by...thanks everyone who took time to reply

Posted

uncle already promised earlier also. Nandita and Alia Bhatt ki voting petti, Alia ki okka vote ekkuva vacchina...DB ki raanu ani sapadham chesadu. @3$% @3$%

 

kompadeesi nuvvu gani Alia ki vote vesava mama ??

Posted

kompadeesi nuvvu gani Alia ki vote vesava mama ??

 

Nenu okkadine kaadhu vuncle, DB mottham vesendhi.
 

Posted

Nenu okkadine kaadhu vuncle, DB mottham vesendhi.
 

 

 

Nanditha ne win ayyinidi man photo-thumb-45827.jpg?_r=1404334766

Posted

ok query is finally working........issue enti ante nenu datecolumn ni convert chesinappudu alias peru orginal column peru icha..adn the same coulmn name iam giving in group by clause ...akkada dengindhi dorikipoyaasa1.gif?1290019852

Posted

for future reference

 

example

 

 

 

 

declare @table1 table

(

tdate varchar(20),

category varchar(20)

)

insert into @table1(tdate,category) values ('08/15/2014','economy')

insert into @table1(tdate,category) values ('08/16/2014','bussiness')

insert into @table1(tdate,category) values ('08/15/2014','bussiness')

insert into @table1(tdate,category) values ('08/17/2014','compact')

insert into @table1(tdate,category) values ('08/16/2014','bussiness')

insert into @table1(tdate,category) values ('08/15/2014','economy')

SELECT tdate, category, COUNT(*)

FROM @table1

GROUP BY tdate, category

--HAVING COUNT(*) > 1

ORDER BY tdate

Posted

ok query is finally working........issue enti ante nenu datecolumn ni convert chesinappudu alias peru orginal column peru icha..adn the same coulmn name iam giving in group by clause ...akkada dengindhi dorikipoyaasa1.gif?1290019852

calling Sardarr

Posted

Nanditha ne win ayyinidi man photo-thumb-45827.jpg?_r=1404334766

Neevu mari comedy vuncle, 1st vote nundi last vote varaku, Alia leading. Neevu madhyalo thread nundi jump.

Posted

this is basically to check the no of duplicates on Keys .

ya it should return number of times a record is repeatin
×
×
  • Create New...