crosstab

How can I sort the columns in a crosstab query, when the column data is dynamic?

你说的曾经没有我的故事 提交于 2020-01-22 14:39:52
问题 I've been doing a bit of research on this topic and I can't seem either find a workable solution, or one that is explained well enough for me to implement. If you've ever created a crosstab query in Access, you are aware that by default Access sorts your columns in alphabetic order. You can change this order by going to the Properties dialog and entering the Column Headings in the order that you prefer. This is a real pain but, as one answerer mentioned on another site, "It's only a pain once

How can I sort the columns in a crosstab query, when the column data is dynamic?

为君一笑 提交于 2020-01-22 14:38:10
问题 I've been doing a bit of research on this topic and I can't seem either find a workable solution, or one that is explained well enough for me to implement. If you've ever created a crosstab query in Access, you are aware that by default Access sorts your columns in alphabetic order. You can change this order by going to the Properties dialog and entering the Column Headings in the order that you prefer. This is a real pain but, as one answerer mentioned on another site, "It's only a pain once

How do I achieve a pivot report in Crystal Reports for Visual Studio?

前提是你 提交于 2020-01-21 07:09:31
问题 I am a rank noob at any reporting but horizontal lines with sub-totals. I have a dataset that comprises the times spent by cars in a carpark. I must produce a table showing a column for each hour and a row for each day, showing the number of entries at a particular time on a particular day. I would find this easier in the RDLC designer, with it's columnar groupings, but I can't even find such a thing in Crystal. Help. 回答1: Assuming the following fields: {table.car_id} and {table.census_time}

supress zero rows in crosstab crystal reports

烂漫一生 提交于 2020-01-16 21:51:16
问题 I have crosstab looks like this Jan Feb Emp1 500 600 Emp2 600 700 Emp3 0 0 I want to hide the row3 as it has zero values. I have seen in crosstab expret to supress empty rows but that doesn't server the purpose. I want output like this Jan Feb Emp1 500 600 Emp2 600 700 回答1: Create a SQL Expression that returns a NULL: -- {@DB_NULL} -- Oracle syntax ( SELECT NULL FROM DUAL ) -- {@DB_NULL} -- MS SQL syntax ( SELECT NULL ) Create a formula field to convert 0 to NULL: -- {@data} If {table.field}

In pandas crosstab, how to calculate weighted averages? And how to add row and column totals?

℡╲_俬逩灬. 提交于 2020-01-15 09:14:27
问题 I have a pandas dataframe with two categorical variables (in my example, city and colour), a column with percentages, and one with weights. I want to do a crosstab of city and colour, showing, for each combination of the two, the weighted average of perc. I have managed to do it with the code below, where I first create a column with weights x perc, then one crosstab with the sum of (weights x perc), another crosstab with the sum of weights, then finally divide the first by the second. It

Unable to use crosstab in Postgres

落爺英雄遲暮 提交于 2020-01-13 08:49:09
问题 Postgres 9.2.1 on OSX 10.9.2. If I run the following crosstab example query: CREATE EXTENSION tablefunc; CREATE TABLE ct(id SERIAL, rowid TEXT, attribute TEXT, value TEXT); INSERT INTO ct(rowid, attribute, value) VALUES('test1','att1','val1'); SELECT * FROM crosstab( 'select rowid, attribute, value from ct where attribute = ''att2'' or attribute = ''att3'' order by 1,2') AS ct(row_name text, category_1 text, category_2 text, category_3 text); I get: ERROR: extension "tablefunc" already exists

Excel Pivot

余生颓废 提交于 2020-01-11 13:15:09
问题 I am an excel newb, wondering if excel has built in functionality to do the following. Turn this data: Name | Activity | Option Bob | Monday Activities | Golf Bob | Tuesday Activities| Kayak Marge | Monday Activities | Spa John | Tuesday Activities| Soccer Liz | Tuesday Activities| Spa Into: Name | Monday Activities | Tuesday Activities Bob | Golf | Kayak Marge | Spa | John | | Soccer Liz | | Spa 回答1: Pivot tables allow you to manipulate and display numerical data, not strings such as "kayak"

How to build frequency matrix in R?

风流意气都作罢 提交于 2020-01-07 16:16:11
问题 Suppose that the existing data frame named as A contains the following data: Time Var T1 loc1 T1 loc2 T1 loc3 T2 loc2 T2 loc2 T2 loc3 T3 loc1 T3 loc3 T3 loc3 I want the output frequency matrix in R in the following format loc1 loc2 loc3 T1 1 1 1 T2 0 2 1 T3 1 0 2 I tried using apply() , table() but could not understand how to use them to get my required output. Can somebody suggest me some functions in R which I can use to get the required output? 回答1: You could go for xtabs in base R xtabs(

How to build frequency matrix in R?

谁都会走 提交于 2020-01-07 16:15:11
问题 Suppose that the existing data frame named as A contains the following data: Time Var T1 loc1 T1 loc2 T1 loc3 T2 loc2 T2 loc2 T2 loc3 T3 loc1 T3 loc3 T3 loc3 I want the output frequency matrix in R in the following format loc1 loc2 loc3 T1 1 1 1 T2 0 2 1 T3 1 0 2 I tried using apply() , table() but could not understand how to use them to get my required output. Can somebody suggest me some functions in R which I can use to get the required output? 回答1: You could go for xtabs in base R xtabs(

PostgreSQL crosstab doesn't work as desired

一曲冷凌霜 提交于 2020-01-06 04:34:06
问题 In this example, I expect the resulting pivot table to have values for 4 columns, but instead there's only values for 2. It should've returned something like this: | time | trace1 | trace2 | trace3 | trace4 | | -----------------------------------------| | t | v | v | v | v | | t | v | v | v | null | | t | null | v | v | v | | t | v | v | null | v | | t | v | null | v | v | |------------------------------------------| but I got this instead: | time | trace1 | trace2 | trace3 | trace4 | | -----