FAQ Database Discussion Community


Different SQL behavior with and without a stored procedure call

sql,sql-server,sql-server-2008,stored-procedures,table-functions
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...

PostgreSQL 9.3: Pivot table query

sql,postgresql,pivot-table,postgresql-9.3,table-functions
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...