All Questions

210
votes
8answers
201836 views

MySQL pivot table

If I have a MySQL table looking something like this: company_name action pagecount ------------------------------- Company A PRINT 3 Company A PRINT 2 Company A PRINT 3 C...
125
votes
6answers
115922 views

SQL Server dynamic PIVOT query?

I've been tasked with coming up with a means of translating the following data: date category amount 1/1/2012 ABC 1000.00 2/1/2012 DEF 500.00 2/1/2012 G...
240
votes
2answers
511842 views

Efficiently convert rows to columns in sql server

I'm looking for an efficient way to convert rows to columns in SQL server, I heard that PIVOT is not very fast, and I need to deal with lot of records. This is my example: -----------------------...
48
votes
1answers
62749 views

MySQL pivot row into dynamic number of columns

Lets say I have three different MySQL tables: Table products: id | name 1 Product A 2 Product B Table partners: id | name 1 Partner A 2 Partner B Table sales: partners_id | produ...
128
votes
5answers
100377 views

PostgreSQL Crosstab Query

Does any one know how to create crosstab queries in PostgreSQL? For example I have the following table: Section Status Count A Active 1 A Inactive 2 B Active 4...
181
votes
6answers
497643 views

Convert Rows to columns using 'Pivot' in SQL Server

Well I guess I am really dense. I have read the stuff on MS pivot tables and I am still having problems getting this correct. I have seen some of you that seem to eat and sleep this stuff, so I just d...
117
votes
6answers
185739 views

SQL Server: Examples of PIVOTing String data

Trying to find some simple SQL Server PIVOT examples. Most of the examples that I have found involve counting or summing up numbers. I just want to pivot some string data. For example, I have a que...
70
votes
7answers
345214 views

Simple way to transpose columns and rows in Sql?

How do I simply switch columns with rows in SQL? Is there any simple command to transpose? ie turn this result: Paul | John | Tim | Eric Red 1 5 1 3 Green 8 ...
67
votes
1answers
1415 views

How to pivot a dataframe

What is pivot? How do I pivot? Is this a pivot? Long format to wide format? I've seen a lot of questions that ask about pivot tables. Even if they don't know that they are asking about pivot table...
12
votes
3answers
74733 views

MySQL pivot table query with dynamic columns

I'm using the following tables for storing product data: mysql> SELECT * FROM product; +---------------+---------------+--------+ | id | name | description | stock | +---------------+------...

Previous Next