qwerty1204 Posted July 25, 2012 Report Posted July 25, 2012 Table lo data ila undi baa col1 col2 1 abc 2 xyz 3 abc o/p ila ravali ante query ela rayali col1 col2 col3 1 abc 2 2 xyz 1 3 abc 2 here col3 is mtnhg but aggregation of col2 GROUP BY use chesi above mention chesinatlu o/p ela tevali (wht should be the query look like)
rapchik Posted July 25, 2012 Report Posted July 25, 2012 [quote name='arey ooo samba' timestamp='1343251419' post='1302200082'] Table lo data ila undi baa col1 col2 1 abc 2 xyz 3 abc o/p ila ravali ante query ela rayali col1 col2 col3 1 abc 2 2 xyz 1 3 abc 2 here col3 is mtnhg but aggregation of col2 GROUP BY use chesi above mention chesinatlu o/p ela tevali (wht should be the query look like) [/quote] what do you mean by aggregation??...do you need how many of the abc are there in table2 ?? or if there 2 or 3 u need the count... Do you need count or distinct or something else.....PLz be clear exactly what you need to see.
Ranga_The_Donga Posted July 25, 2012 Report Posted July 25, 2012 select col1, col2, count(*) from table group by col1,col2
chandrabhai6 Posted July 25, 2012 Report Posted July 25, 2012 Select col1 , col2, (select count(1) from tableX A where A.col2=B.col2 group by col2) From TableX B
chandrabhai6 Posted July 25, 2012 Report Posted July 25, 2012 [quote name='Jeedeelu' timestamp='1343252711' post='1302200234'] select col1, col2, count(*) from table group by col1,col2 [/quote] Idi wrong bayya
Thurum_Kaan Posted July 25, 2012 Report Posted July 25, 2012 [color=#00008B][background=transparent]SELECT[/background][/color][background=transparent] col1[/background][background=transparent],[/background][background=transparent] col2[/background][background=transparent],[/background][background=transparent] col3[/background][background=transparent]=[/background][background=transparent]count [/background][background=transparent]( * )[/background] [color=#00008B][background=transparent]INTO[/background][/color][background=transparent] holdkey [/background][color=#00008B][background=transparent]FROM[/background][/color][background=transparent] t1 [/background][color=#00008B][background=transparent]GROUP[/background][/color][background=transparent] [/background][color=#00008B][background=transparent]BY[/background][/color][background=transparent] col1[/background][background=transparent],[/background][background=transparent] col2 [/background][color=#00008B][background=transparent]HAVING[/background][/color][background=transparent] count [/background][background=transparent]( * )[/background][background=transparent] [/background][background=transparent]>[/background][background=transparent] [/background][color=#800000][background=transparent]1[/background][/color]
jaffanajeffada Posted July 25, 2012 Report Posted July 25, 2012 ila try chey, not sure select distinct a.col1, a.col2, b.col3 from table1 a, (select col2, count(*) as col3 from table1 group by col2) b where a.col2= b.col2
Ranga_The_Donga Posted July 25, 2012 Report Posted July 25, 2012 [quote name='Thurum_Kaan' timestamp='1343252946' post='1302200266'] [color=#00008B][background=transparent]select[/background][/color] [background=transparent] col1[/background][background=transparent],[/background][background=transparent] col2[/background] [color=#00008B][background=transparent]from[/background][/color] [background=transparent] [/background][color=#00008B][background=transparent]table[/background][/color] [color=#00008B][background=transparent]GROUP[/background][/color][background=transparent] [/background][color=#00008B][background=transparent]BY[/background][/color] [background=transparent] col12[/background][background=transparent],[/background][background=transparent] col2[/background] [color=#00008B][background=transparent]HAVING count(*)>1[/background][/color] [/quote] idhi correct anukunta...
chandrabhai6 Posted July 25, 2012 Report Posted July 25, 2012 Try mine sure shot working [img]http://www.gifsoup.com/view1/1444039/brahmi-hug-o.gif[/img]
Ranga_The_Donga Posted July 25, 2012 Report Posted July 25, 2012 [quote name='chandrabhai6' timestamp='1343252939' post='1302200265'] Idi wrong bayya [/quote] oops...ippude choosa..
chandrabhai6 Posted July 25, 2012 Report Posted July 25, 2012 [quote name='Thurum_Kaan' timestamp='1343252946' post='1302200266'] [color=#00008B][background=transparent]SELECT[/background][/color][background=transparent] col1[/background][background=transparent],[/background][background=transparent] col2[/background][background=transparent],[/background][background=transparent] col3[/background][background=transparent]=[/background][background=transparent]count [/background][background=transparent]( * )[/background] [color=#00008B][background=transparent]INTO[/background][/color][background=transparent] holdkey [/background][color=#00008B][background=transparent]FROM[/background][/color][background=transparent] t1 [/background][color=#00008B][background=transparent]GROUP[/background][/color][background=transparent] [/background][color=#00008B][background=transparent]BY[/background][/color][background=transparent] col1[/background][background=transparent],[/background][background=transparent] col2 [/background][color=#00008B][background=transparent]HAVING[/background][/color][background=transparent] count [/background][background=transparent]( * )[/background][background=transparent] [/background][background=transparent]>[/background][background=transparent] [/background][color=#800000][background=transparent]1[/background][/color] [/quote] Wrong
qwerty1204 Posted July 25, 2012 Author Report Posted July 25, 2012 [quote name='ReddyGaru' timestamp='1343252693' post='1302200230'] what do you mean by aggregation??...do you need how many of the abc are there in table2 ?? or if there 2 or 3 u need the count... Do you need count or distinct or something else.....PLz be clear exactly what you need to see. [/quote] basically in my col3 I need to know how many times the value of col2 is repeated in the entire table baa
Recommended Posts