Pivot tables in SQL Server. A simple sample.

The other day I was wondering about how to use Pivot tables in SQL Server with SQL, and I didn’t find any simple examples on this. So I had to do my own and I thought I’d share this here and also as to have as a future reference for myself. So let’s start with a fictional scenario.In this case we have lots of vendors who report in their daily income to us, for this we have a simple table that looks like this. Baca lebih lanjut

SQL Product Highlight Red Gate Software – SQL Monitor SQL Server performance monitoring and alerting – SQL Monitor offers an easy entrance to advanced server monitoring with a simple design that’s a refreshing change from the status quo. Red Gate have added custom metrics and user roles to the product without spoiling its ease-of-use, to help you answer that timeless question, ‘How healthy are your servers?’ Learn more! SQL Server Jobs SQL BI Developer Fort Mill, SC Salary = $70-90K Industry = Financial SQL Developer Portland, OR Salary = $70-75K Industry = Benefits solutions provider Review all opportunities Crosstab queries using PIVOT in SQL Server

Problem

In SQL Server 2000 there was not a simple way to create cross-tab queries, but a new option first introduced in SQL Server 2005 has made this a bit easier. We took a look at how to create cross-tab queries in SQL Server 2000 in this previous tip and in this tip we will look at this new feature to allow you produce cross-tab results. Baca lebih lanjut

Fix : Error : Incorrect syntax near . You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel

have seen developer confused many times when they receive following error message.

Msg 325, Level 15, State 1, Line 7
Incorrect syntax near . You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel. Baca lebih lanjut

Curhat SQL akhir pekan

Wow data yang tersimpan didatabase tidaklah berguna jika tidak bisa mengelolanya . misalkan manajemen mau minta laporan detail dari tahun 2011 s/d 2012 ,diurutkan pertahun, persemester, perquartal, perbulan dan perminggu.. belum lagi master distributornya terpisah, harganya juga terpisah cuma diambil yang paling update aja, trus ada tabel discount juga per item beda2 tiap distributor
Nah loh… gimana ya querynya ?? Baca lebih lanjut