Questions tagged [crosstab]

A cross tab, also known as a "pivot table", is a method of summarizing data in tabular form. Typically, these have a category column in the left hand side, and multiple summary columns to the right. Each different category will have its own row. Be sure to also include the relevant language tag (python, R, sql-server etc.) on your question.

Resources:

1549 questions
4
votes
1 answer

Merging Two Crosstabs with Dynamic Row Headers into one

Using MS Access I have two cross tab queries summarizing my data. One gets me the total count of the rows of data by location and fiscal quarter; the other query gets me the percent that meet a criteria by location and fiscal quarter. Examples…
thornomad
  • 6,707
  • 10
  • 53
  • 78
4
votes
3 answers

Speed up quantile calculation

I am using the Hmisc Package to calculate the quantiles of two continous variables and compare the results in a crosstable. You find my code below. My problem is that the calculation of the quantiles takes a considerable amount of time if the…
majom
  • 7,863
  • 7
  • 55
  • 88
4
votes
2 answers

Create column from query data

Test data: create temp table l (id integer,name text); create temp table t (id integer); create temp table t_i18n(id integer,l_id integer,t_id integer,name text); insert into l(id, name) values (1, 'lang_1'), (2, 'lang_2'); insert into t(id)…
cetver
  • 11,279
  • 5
  • 36
  • 56
4
votes
1 answer

summary {Hmisc} drops category?

I am trying to get a crosstab with percentages from this file using Hmisc. But why is summary() dropping a category ("OTHERS") from the variable OCCUPATION? library(Hmisc) summary(ID ~ OCCUPATION, data=df, method="reverse") Output: Descriptive…
user702432
  • 11,898
  • 21
  • 55
  • 70
4
votes
2 answers

TSQL - Unpivot multiple columns

How can I unpivot multiple columns in "one"? Right now I have an unpivot for each column but this creates a lot of empty rows. See the screenshot please. At the top you see the input data. At the moment I'm at the table in the middle with this…
SvenB
  • 139
  • 3
  • 10
4
votes
4 answers

SQL Select to combine row values in output table using Pivot or CASE

I am using a PostgreSQL database and have a table as follows: -------------------------------------- | Date | MetricType | MetricValue | -------------------------------------- | date1 | MetricA | val …
Jordan Ell
  • 1,745
  • 3
  • 16
  • 24
4
votes
3 answers

crosstab postgres - line to column

On my project, the data model changed and I have to do a new request to get information but in the past it looks like all data are in the same line, but now a part of that data are in an other table, and it returns me column. So my request…
4
votes
1 answer

Jasper Reports wide crosstab on multiple pages

I have a crosstab with many columns but only a few rows. When I generate the report the crosstab reuses the empty space below the rows from one page and renders the next columns for the same rows. This way several pages are compacted vertically on…
Tiberiu
  • 508
  • 7
  • 17
4
votes
1 answer

Crystal Report - Multiple Crosstabs with Different Record Selection Criteria

I’m using Crystal Report 2011 and I would like to know if it is possible to generate two crosstab tables with different record selection in the same report? For example, I have the following dataset: SchoolID QuestionID …
Asma
  • 133
  • 1
  • 1
  • 6
4
votes
1 answer

Crystal Reports Cross-Tab, Grouping by Database Field

Currently I have a cross tab in my report, reading all of the products in I wish to display. They are already grouped under their relevant customer who is associated with them, however I want to add a further grouping to distinguish between…
William
  • 6,332
  • 8
  • 38
  • 57
4
votes
5 answers

Crosstab column group sorting

I am trying to sort the column group in crosstab but iReport is applying its own sorting by name ascending. I tried inserting "Order By Exp.", but it didn't work. (Field not found error!) What is the correct way to add our own sorting by…
user1120946
  • 171
  • 1
  • 2
  • 13
3
votes
3 answers

SQL SELECT statement, column names as values from another table

I'm working on a database which has the following table: id location 1 Singapore 2 Vancouver 3 Egypt 4 Tibet 5 Crete 6 Monaco My question is, how can I produce a query from this which would result in column names like the following…
user1277546
  • 8,652
  • 3
  • 17
  • 25
3
votes
2 answers

Sql Pivot table with two cross tab and multiple columns

I am trying to build a table with two cross tabs and multiple columns. I have this so far, and when I run it create table test2(city nvarchar(10), race nvarchar(30), sex nvarchar(10), age int) insert into test2 values ('Austin', …
user973671
  • 1,620
  • 6
  • 27
  • 39
3
votes
2 answers

How to pivot/cross-tab data in Python 3?

What is the best solution to pivot/cross-tab tables in Python 3? Is there a built-in function that will do this? Ideally, I'm looking for a Python 3 solution that does not have external dependencies. For example, given a nested list: nl =…
drbunsen
  • 10,139
  • 21
  • 66
  • 94
3
votes
1 answer

Display multiple values of a column in one row in PostgreSQL

I have a query like this: select to_date(to_char(registime, 'YYYY-MM'),'YYYY-MM') as dt,count(id) as total_call from all_info where alarm_id is null group by dt order by dt And the result just like this: dt total_call …
diligent
  • 2,282
  • 8
  • 49
  • 64