I have rows of data in a table for each day of the month. This database is switching from Oracle to SQL Server. When in oracle, I used a TRUNC function to get one row for every month like:(select distinct sample_plot, plot_name,TRUNC(sample_start_date, 'MM') coll_date, TO_CHAR(sample_start_date,'Month'), TO_CHAR(sample_start_date,'YYYY'), sample_submit_date, sample_submit_date - (TRUNC(sample_start_date, 'MM') + 75)from sample_info inner join stnplot_infoon sample_plot = plot_id and....))
Now I am trying to get the same output from the SQL Server database and getting 4/5/6 rows for each month from this query:(SELECT DISTINCT PLOT_ID, PLOT_NAME, SAMPLE_START_DATE COLL_DATE,DATENAME(MONTH,SAMPLE_START_DATE), DATENAME(YEAR,SAMPLE_START_DATE), SAMPLE_SUBMIT_DATE,DATEDIFF(DAY,DATEADD(DAY,61,SAMPLE_START_DATE), SAMPLE_SUBMIT_DATE) FROM SAMPLE_INFO INNER JOIN STATION_INFOON SAMPLE_STATION = STATION_ID AND ...));Sample Output:-----------------------------------------------1028 ABC 2007-03-01 March 2007 2008-09-05 4931028 ABC 2007-03-07 March 2007 2008-09-05 4871028 ABC 2007-03-13 March 2007 2008-09-05 4811028 ABC 2007-03-19 March 2007 2008-09-05 4751028 ABC 2007-03-25 March 2007 2008-09-05 4691028 ABC 2007-03-31 March 2007 2008-09-05 463-----------------------------------------------
Is there any way I can do this? Thanks.