FAQ Database Discussion Community

PostgreSQL 9.3: Pivot table query

I want to show the pivot table(crosstab) for the given below table. Table: Employee CREATE TABLE Employee ( Employee_Number varchar(10), Employee_Role varchar(50), Group_Name varchar(10) ); Insertion: INSERT INTO Employee VALUES('EMP101','C# Developer','Group_1'), ('EMP102','ASP Developer','Group_1'), ('EMP103','SQL Developer','Group_2'), ('EMP104','PLSQL Developer','Group_2'), ('EMP101','Java Developer',''), ('EMP102','Web Developer',''); Now I want to show the pivot table for...

Different SQL behavior with and without a stored procedure call

Running MS SQL Server 2008, if I execute the following query, it runs quite fast (2 seconds or less) and returns 906 rows: DECLARE @ValueTime datetime2 DECLARE @PriceUpdTime datetime2 SELECT @ValueTime = '2014-11-28 23:00:00.000000' SELECT @PriceUpdTime = CURRENT_TIMESTAMP SELECT * FROM dbo.fMyTableFunction(@PriceUpdTime, @ValueTime) AS prices However, when I move this...