Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Power Lifting Lever Belt
SkullVamp
Updated:
Saturday at 10:32 PM
Ad icon
port.lk Domain for sale
Lankan-Tech
Updated:
Saturday at 3:55 PM
Colombo
Kaduwela - Two Storey House for Sale
dilrasan
Updated:
Jun 11, 2026
Ad icon
Wechat qr verification
Pawan2005
Updated:
Jun 11, 2026
🚀 GOOGLE AI PRO 18 MONTHS ACTIVATION 🚀
sayuru bandara
Updated:
Jun 10, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
SQL danna aya enna....
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="0cean" data-source="post: 22634499" data-attributes="member: 562898"><p>Query eka nam therune naha. </p><p>Habayi wade nam hari. <img src="/styles/default/xenforo/smilies/default/yes.gif" class="smilie" loading="lazy" alt=":yes:" title="Yes :yes:" data-shortname=":yes:" /></p><p></p><p>Thanks machan. <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /></p><p></p><p>[CODE]</p><p>declare @mytable table(id int, stname char(10), birthday date);</p><p>insert into @mytable values (1, 'saman', '2015.01.02')</p><p>insert into @mytable values (2, 'nimal', '2016.02.02')</p><p>insert into @mytable values (3, 'amal', '2017.05.02')</p><p>insert into @mytable values (4, 'kamal', '2015.09.02')</p><p>insert into @mytable values (5, 'nayana', '2015.08.02')</p><p></p><p>select x.*, coalesce( y.count,0) from </p><p>(SELECT distinct year(birthday) year,a.*</p><p>FROM @mytable ,</p><p>( select 1 'month'</p><p>union</p><p>select 2 'month'</p><p>union</p><p>select 3 'month'</p><p>union</p><p>select 4 'month'</p><p>union</p><p>select 5 'month'</p><p>union</p><p>select 6 'month'</p><p>union</p><p>select 7 'month'</p><p>union</p><p>select 8 'month'</p><p>union</p><p>select 9 'month'</p><p>union</p><p>select 10 'month'</p><p>union</p><p>select 11 'month'</p><p>union</p><p>select 12 'month'</p><p>) a) x </p><p>left outer join </p><p>(</p><p>SELECT year(birthday) year , month (birthday) month ,count(*) count FROM @mytable</p><p>group by year(birthday) ,month (birthday)) y</p><p>on x.year=y.year and x.month=y.month</p><p>[B]order by x.year, x.month[/B]</p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="0cean, post: 22634499, member: 562898"] Query eka nam therune naha. Habayi wade nam hari. :yes: Thanks machan. :) [CODE] declare @mytable table(id int, stname char(10), birthday date); insert into @mytable values (1, 'saman', '2015.01.02') insert into @mytable values (2, 'nimal', '2016.02.02') insert into @mytable values (3, 'amal', '2017.05.02') insert into @mytable values (4, 'kamal', '2015.09.02') insert into @mytable values (5, 'nayana', '2015.08.02') select x.*, coalesce( y.count,0) from (SELECT distinct year(birthday) year,a.* FROM @mytable , ( select 1 'month' union select 2 'month' union select 3 'month' union select 4 'month' union select 5 'month' union select 6 'month' union select 7 'month' union select 8 'month' union select 9 'month' union select 10 'month' union select 11 'month' union select 12 'month' ) a) x left outer join ( SELECT year(birthday) year , month (birthday) month ,count(*) count FROM @mytable group by year(birthday) ,month (birthday)) y on x.year=y.year and x.month=y.month [B]order by x.year, x.month[/B] [/CODE] [/QUOTE]
Insert quotes…
Verification
Payakata winadi keeyak tibeda?
Post reply
Top
Bottom