hi friend
I used the following query with sql server 2008 to select group by records
SELECT sum(ljoin)as lct, sum(rjoin)as rct, CONCAT(DATE_FORMAT(DATE_ADD(date, INTERVAL(1-DAYOFWEEK(date)) DAY),'%Y-%m-%e'),' TO ', DATE_FORMAT(DATE_ADD(date, INTERVAL(7-DAYOFWEEK(date)) DAY),'%Y-%m-%e'))AS DateRangeFROM Pairs_Details WHERE userid='jitu'GROUPBY YEARWEEK(date)
it return the following error 'DAYOFWEEK' is not a recognized built-in function name.
But I can not get my desire result there are my following table, data and desire output which I want
Pairs_Details
table definition:
CREATETABLE[dbo].[Pairs_Details]([sno][int]IDENTITY(1,1)NOTNULL,[userid][nvarchar](50)NULL,[date][datetime]NULL,[ljoin][int]NULL,[rjoin][int]NULL)ON[PRIMARY]
Example data:
sno userid date ljoin rjoin1 jitu 2014-01-2115:48:24.0001NULL2 jitu 2014-01-2215:48:24.000NULL13 tetu1234 2014-01-2215:48:24.0001NULL4 jitu 2014-01-2415:48:24.000NULL15 saurbh123 2014-01-2515:48:24.0001NULL6 jitu 2014-01-2615:48:24.0001NULL7 tetu1234 2014-01-2816:40:05.000NULL18 jitu 2014-01-2816:40:05.000NULL1
Desired output: for perticular userid 'jitu'
userid | ljoin | rjoin | DATERANGE |-----------------------------------------------------------------------
jitu |2|2|2014-01-2115:48:24.00TO2014-01-2716:40:05.000|
please any can help me.
thanks.
Jitendra Kumar Sr. Software Developer at Ruvixo Technologies 7895253402