Jump to content

Sql Groupby Multiple Columns(Sub Grouping) Help Plz


Recommended Posts

Posted

example data is

 

date column is in varchar here

 

 

transactiondate      Category    

 

08/15/2014            economy

08/16/2014            bussiness

08/15/2014            bussiness

08/17/2014            compact

08/16/2014            bussiness

08/15/2014           economy

 

 

 

 

the result i want to see  is

 

 

 

08/15/2014     economy    2

08/15/2014     bussiness  1

08/16/2014    bussiness   2

08/17/2014    compact     1

 

 

iam trying like this but its not working

 

 

SELECT TRANSACTIONDATE,

CATEGORY,

COUNT(CATEGORY)

 

FROM TABLE

GROUP BY  TRANSACTIONDATE,  CATEGORY 

 

 

  • 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

SELECT  

CATEGORY,

COUNT(CATEGORY)

 

FROM TABLE

GROUP BY    CATEGORY   ---idhi try chesi results vosthundoo chudu mayaa oka sari (TRANSACTIONDATE thesesaa) ... nuvvu rasindhi aithy correct ee but just trying other way  

Posted

you dont need to do multiple baa...just try this you will get your result!

 

SELECT TRANSACTIONDATE,

CATEGORY,

COUNT(CATEGORY)

FROM TABLE

GROUP BY  TRANSACTIONDATE

Posted

select clause lo unnavu group by clause lo lekuntee SQL thanthundhi kadha ARYA bhayaaa 

 

you dont need to do multiple baa...just try this you will get your result!

 

SELECT TRANSACTIONDATE,

CATEGORY,

COUNT(CATEGORY)

FROM TABLE

GROUP BY  TRANSACTIONDATE

 

 

Posted

select clause lo unnavu group by clause lo lekuntee SQL thanthundhi kadha ARYA bhayaaa 

 

 

 

you dont need to do multiple baa...just try this you will get your result!

 

SELECT TRANSACTIONDATE,

CATEGORY,

COUNT(CATEGORY)

FROM TABLE

GROUP BY  TRANSACTIONDATE

 

 

 

 

SELECT  

CATEGORY,

COUNT(CATEGORY)

 

FROM TABLE

GROUP BY    CATEGORY   ---idhi try chesi results vosthundoo chudu mayaa oka sari (TRANSACTIONDATE thesesaa) ... nuvvu rasindhi aithy correct ee but just trying other way  

 

CORRECT 

 

 

 

 

 

ADHI ALREADY TRY CHESANU....ala chesthe its grouping correctly according to category kaani naku ikkada perday/per category/count kavali

Posted

example data is

 

date column is in varchar here

 

 

transactiondate      Category    

 

08/15/2014            economy

08/16/2014            bussiness

08/15/2014            bussiness

08/17/2014            compact

08/16/2014            bussiness

08/15/2014           economy

 

 

 

 

the result i want to see  is

 

 

 

08/15/2014     economy    2

08/15/2014     bussiness  1

08/16/2014    bussiness   2

08/17/2014    compact     1

 

 

iam trying like this but its not working

 

 

SELECT TRANSACTIONDATE,

CATEGORY,

COUNT(CATEGORY)

 

FROM TABLE

GROUP BY  TRANSACTIONDATE,  CATEGORY 

 

Baa, use partition by clause over Rank or row number.
 

Posted

Baa, use partition by clause over Rank or row number.
 

i thought this is to delete duplicate rows...group by ela use avuthundhi?

Posted

SELECT TRANSACTIONDATE,

CATEGORY,

COUNT(*)

FROM TABLE

GROUP BY  TRANSACTIONDATE,  CATEGORY

Posted

:4_12_13:  :4_12_13:  ... yes this should work , count(*) ,...

SELECT TRANSACTIONDATE,

CATEGORY,

COUNT(*)

FROM TABLE

GROUP BY  TRANSACTIONDATE,  CATEGORY

 

Posted

i thought this is to delete duplicate rows...group by ela use avuthundhi?

 

Wait, I read your question wrong.

 

Thats your qury.

 

SELECT TRANSACTIONDATE,

CATEGORY,

COUNT(CATEGORY)

 

FROM TABLE

GROUP BY  TRANSACTIONDATE,  CATEGORY

 

You are using the Category in the group by clause. Remove the category in the Group by clause and try.

Posted

:4_12_13:  :4_12_13:  ... yes this should work , count(*) ,...

idi work cheyakapothe nenu inka db ki raanu :police:

Posted

Wait, I read your question wrong.

 

Thats your qury.

 

SELECT TRANSACTIONDATE,

CATEGORY,

COUNT(CATEGORY)

 

FROM TABLE

GROUP BY  TRANSACTIONDATE,  CATEGORY

 

You are using the Category in the group by clause. Remove the category in the Group by clause and try.

nenu ade seppanu...

Posted

SELECT TRANSACTIONDATE,

CATEGORY,

COUNT(*)

FROM TABLE

GROUP BY  TRANSACTIONDATE,  CATEGORY

 

Nee output ki edhe correct...

Posted

Wait, I read your question wrong.

 

Thats your qury.

 

SELECT TRANSACTIONDATE,

CATEGORY,

COUNT(CATEGORY)

 

FROM TABLE

GROUP BY  TRANSACTIONDATE,  CATEGORY

 

You are using the Category in the group by clause. Remove the category in the Group by clause and try.

 

 

select clause lo unnavu group by clause lo lekuntee SQL thanthundhi kadha ARYA bhayaaa 

×
×
  • Create New...