Please help with this SQL table query, I have the table
+ - ------------------------------------------- + | Date code 1 Date code 2 Date code 3 Date code 4 | + --------------------------------------------- + | 2014-10-01 Faucet 2014_10_04 | | 2014_10_02 2014_10_01 tap 2014_10_04 | | 2014_10_02 tap 2014_10_01 2014_10_04 | | 2014_10_02 tap 2014_10_01 tap | + --------------------------------------------- +// Code > If the user is giving input such as- FromDate = '2014-10-01' and ToDate = '2014-10 = 05' I have to show
+ - ------------------------------------------------- - --------------- + | Activity DateTit Date 1_Cnt DateCall 2_Cnt DateCall 3_Cnt DateCol4_Cnt | + ------------------------------------------------- ----------------- + | 2014-10-01 1 1 2 0 | | 2014-10-02 3 0 0 0 | | 2014-10-03 0 0 0 0 | | 2014-10-04 0 0 3 3 | + ------------------------------------------------- ----------------- +
what I have to show, number of activity on a partial date
is what Calculate the activity from date 1_ATT activity, date column 1 activity_date, calculation (1), where my date 'column2 @ @ @ and @ToDate select all between' Date2_ACTY 'activity, Date column 2 Activity_Date Activity from myTable (count) (1) Activity_count where dateColumn2 @frondate and @ToDate are all .....
column left for now
Please Please help solve
The problem is I am receiving DateCol_Acty
, DateCo2_Acty
and so on, as column values do not have columns: (
It may be that a UNPIVOT
is a new PIVOT
What will happen after this? It is not beautiful, but it seems to me that this is the right result, except for losing empty dates, but it may be the door of joining a column with all the dates in the left category. Be determined
MS SQL Server 2012 schema setup .
Comments
Post a Comment