2 X-Axis row, 1 Y-Axis Column and 2 Z-Axis Value Pivot Table SQL Server 2008 query -
i have sql server database table below-
id | consignee | shipper | lss | cm1 | month 1 | hnm | | 101 | 25 | jan 2 | hnm | b | 102 | 35 | jan 3 | hnm | | 103 | 45 | feb
i want have output below-
consignee | shipper | jan | feb | | cm1 | lss | cm1 | lss| hnm | | 25 | 1 | 45 | 1 | hnm | b | 35 | 1 | 0 | 0 |
here count function applied on lss , sum applied on cm1. don't know if possible in sql server query. have seen searching people converting rows columns or 1 x-axis, 1 y-axis , 1 z-axis queries, nothing this. can on excel using pivot, need data database format , export excel file.
note: working on asp .net application using c# , oledb.
yes. possible.
select consignee , shipper , jan_cm1 = max (case when month = 'jan' cm1 end), jan_lss = max (case when month = 'jan' lss end), feb_cm1 = max (case when month = 'feb' cm1 end), feb_lss = max (case when month = 'feb' lss end) yourtable group consignee , shipper
Comments
Post a Comment