ChampakDas Posted July 25, 2012 Report Posted July 25, 2012 naa image not visible ani talk vachindhi... edigo query SELECT COUNT(A.COL1) AS Count, A.COL2,A.COL1 FROM ABC A JOIN ABC B ON A.COL2=B.COL2 GROUP BY A.COL1,A.COL2 Output: 2 abc 1 2 abc 3 1 xyz 2
qwerty1204 Posted July 25, 2012 Author Report Posted July 25, 2012 [quote name='taarachowdary' timestamp='1343257536' post='1302200757'] count(fieldname) but you used count(sustrr(fn,9,13) after substring it is no more a field name i guess i dd not go through entire thread but i found some thing fish here [/quote] hmm..emo baa..not sure
qwerty1204 Posted July 25, 2012 Author Report Posted July 25, 2012 [quote name='kiss4amiss' timestamp='1343257445' post='1302200755'] [/quote] Thanks baa bhayaa..deniki ela rayali query col1 col2 col3 1 abc 123 2 xyz 456 3 abc 123 o/p should be: col1 col2 col3 col4 1 abc 123 2 2 xyz 456 1 3 abc 123 2 kind of same requirement but here col2 and col3 needs to tie up to-gether i.e. aggregation needs to be done on those two columns
qwerty1204 Posted July 25, 2012 Author Report Posted July 25, 2012 [quote name='DaVinci' timestamp='1343258299' post='1302200823'] Solutions dorikinda? [/quote] this one worked baa SELECT b.RECORD_ID AS COL1, SUBSTR(b.SOURCE_RECORD,13,9) AS COL2, (SELECT Count(SUBSTR(a.SOURCE_RECORD,13,9)) FROM RAWINPTS."RAW_IMF" a WHERE SUBSTR(a.SOURCE_RECORD,13,9) = SUBSTR(b.SOURCE_RECORD,13,9) GROUP BY SUBSTR(a.SOURCE_RECORD,13,9) ) AS COL3 FROM RAWINPTS."RAW_IMF" b ;
qwerty1204 Posted July 25, 2012 Author Report Posted July 25, 2012 [quote name='ChampakDas' timestamp='1343257866' post='1302200775'] naa image not visible ani talk vachindhi... edigo query SELECT COUNT[b](A.COL1)[/b] AS Count, A.COL2,A.COL1 FROM ABC A JOIN ABC B ON A.COL2=B.COL2 GROUP BY A.COL1,A.COL2 Output: 2 abc 1 2 abc 3 1 xyz 2 [/quote] DB2 loo ravadam ledu baa for this query aa bold chesina part loo A.COL2 undali anukunta kada?
pandemkodi Posted July 25, 2012 Report Posted July 25, 2012 mama neeku enni duplicate values vunnyo check cheskovala ihtey DS lo cheyyochu clusterkey add chey chalu mana thread lo choodu okasari
qwerty1204 Posted July 25, 2012 Author Report Posted July 25, 2012 [quote name='pandemkodi' timestamp='1343259156' post='1302200889'] mama neeku enni duplicate values vunnyo check cheskovala ihtey DS lo cheyyochu clusterkey add chey chalu mana thread lo choodu okasari [/quote] yaa chusanu baa ikkada enni duplicates ani kadu baa...oka column create cheyali by counting the no.of times it repeated ani...DS loo aggregatoe stage use chesi cheyachu..but basic SQL skills marchipotunna ani
kiss4amiss Posted July 26, 2012 Report Posted July 26, 2012 [quote name='arey ooo samba' timestamp='1343258363' post='1302200831'] Thanks baa bhayaa..deniki ela rayali query col1 col2 col3 1 abc 123 2 xyz 456 3 abc 123 o/p should be: col1 col2 col3 col4 1 abc 123 2 2 xyz 456 1 3 abc 123 2 kind of same requirement but here col2 and col3 needs to tie up to-gether i.e. aggregation needs to be done on those two columns [/quote] SQL> select * from test; COL1 COL2 COL3 ---------- ---------- ---------- 1 abc 123 2 xyz 456 3 abc 123 4 xyz 789 SQL> SELECT b.col1, b.col2, b.col3, (SELECT [i]Count[/i](a.col2) FROM test a WHERE a.col2 = b.col2 AND a.col3 = b.col3 GROUP BY a.col2) AS col4 FROM test b; COL1 COL2 COL3 COL4 ---------- ---------- ---------- ---------- 1 abc 123 2 2 xyz 456 1 3 abc 123 2 4 xyz 789 1 okasari test chesko baa...
Recommended Posts