crosstab

Access: “crosstab” query effect for non-numeric data

有些话、适合烂在心里 提交于 2019-12-24 07:59:35
问题 I am using Access 2007 and need help creating a query. If this is crazy long, sorry! I figure the more details the better understanding. I am not a programmer--I hope someone will help. I need to know how to collapse/summarize/roll up non-numeric data into a single row that shares a characteristic/value. What I want is like a crosstab query because I want unique cell values from different rows pivoted/displayed in columns along one row for that shared/common value. However, my data isn't

Dynamically create columns from rows in MySQL [duplicate]

穿精又带淫゛_ 提交于 2019-12-24 02:12:16
问题 This question already has answers here : MySQL - Rows to Columns (12 answers) Closed 5 years ago . I have the following tables: "crawlresults" id | url | fk_crawljobs_id --------------------------------------------- 1 | shop*com/notebooks | 1 2 | shop*com/fridges | 1 3 | website*com/lists | 2 "extractions" id | fk_extractors_id | data | fk_crawlresults_id --------------------------------------------------------------- 1 | 1 | 123.45 | 1 2 | 2 | notebook | 1 3 | 3 | ibm.jpg | 1 4 | 1 | 44.5 |

Group By and add columns

自闭症网瘾萝莉.ら 提交于 2019-12-24 02:09:33
问题 I have a table named 'ward_councillors' and two columns 'ward' and 'councillor'. This table contains a list of all of the councillors and the ward they are responsible for. Each ward has three councillors and what i'd need to do is group by so that I have one distinct record for each ward and three new columns with the three councillors responsible for that ward in each. For example currently have: WARD | COUNCILLOR ward a | cllr 1 ward a | cllr 2 ward a | cllr 23 ward b | cllr 4 ward b |

PostgreSQL Query with dynamic columns and counts from join

流过昼夜 提交于 2019-12-24 00:49:59
问题 I'm probably overthinking this, because I'm not really sure where to start... But here goes: I have the following Tables students assessments students_assessments Expected output First query for "Attempts" student_id | Assessment 1 | Assessment 2 | Assessment 3 | Assessment 4 1 3 1 2 0 2 1 0 0 0 3 2 1 1 0 4 5 3 3 0 5 1 5 0 0 6 2 1 2 0 Second query for "passed" student_id | Assessment 1 | Assessment 2 | Assessment 3 | Assessment 4 1 t t f f 2 t t f f 3 t t f f 4 t t t f 5 t t f f 6 t t t f The

Convert multiple rows into one row with multiple columns

只愿长相守 提交于 2019-12-23 02:06:32
问题 I've a table containing information as follows: idnumber applic_id cctype ccnumber --------- ------------ -------- ---------- 1 23 1 223445 2 23 2 345567 I need a query that an make this: idnumber applic_id cctype ccnumber idnumber applic_id cctype ccnumber --------- ------------ -------- ---------- --------- ------------ -------- ---------- 1 23 1 223445 2 23 2 345567 Is anyone have a clue? I'm using PostgreSQL 8.3. 回答1: You can use CASE statements for simple queries. Or use the crosstab()

PostgreSQL and pivot tables using crosstab function

ぃ、小莉子 提交于 2019-12-22 17:39:09
问题 I have a problem with creating a pivot table in PostgreSQL using the crosstab() function. It works well but it produces multiple records for the same client_id . How can I avoid this? Here is the SQL: SELECT * FROM crosstab('SELECT client_id ,extract(year from date) ,sum(amount) from orders group by extract(year from date) ,client_id' ,'SELECT extract(year from date) FROM orders GROUP BY extract(year from date) order by extract(year from date)') AS orders( row_name integer, year_2001 text,

PostgreSQL and pivot tables using crosstab function

青春壹個敷衍的年華 提交于 2019-12-22 17:38:05
问题 I have a problem with creating a pivot table in PostgreSQL using the crosstab() function. It works well but it produces multiple records for the same client_id . How can I avoid this? Here is the SQL: SELECT * FROM crosstab('SELECT client_id ,extract(year from date) ,sum(amount) from orders group by extract(year from date) ,client_id' ,'SELECT extract(year from date) FROM orders GROUP BY extract(year from date) order by extract(year from date)') AS orders( row_name integer, year_2001 text,

Get records for last 10 dates

喜欢而已 提交于 2019-12-22 13:52:59
问题 I have scenario where I have to get last 10 dates when books are sold. Consider below example Store Book ---------- -------------------- Id Name Id Name Sid Count Date 1 ABC 1 XYZ 1 20 11/11/2015 2 DEF 2 JHG 1 10 11/11/2015 3 UYH 1 10 15/11/2015 4 TRE 1 50 17/11/2015 I have get result based on stored.Id . When I pass the ID, the report should be generated with bookname sold date and count of sold copies. Output: BookName 11/11/2015 15/11/2015 17/11/2015 XYZ 20 -- -- JHG 10 -- -- UYH -- 10 --

Get records for last 10 dates

孤街浪徒 提交于 2019-12-22 13:52:50
问题 I have scenario where I have to get last 10 dates when books are sold. Consider below example Store Book ---------- -------------------- Id Name Id Name Sid Count Date 1 ABC 1 XYZ 1 20 11/11/2015 2 DEF 2 JHG 1 10 11/11/2015 3 UYH 1 10 15/11/2015 4 TRE 1 50 17/11/2015 I have get result based on stored.Id . When I pass the ID, the report should be generated with bookname sold date and count of sold copies. Output: BookName 11/11/2015 15/11/2015 17/11/2015 XYZ 20 -- -- JHG 10 -- -- UYH -- 10 --

Crosstab Sorting in JasperReports

无人久伴 提交于 2019-12-22 11:28:09
问题 I have a column group in a Crosstab that is a String. It uses the field SectionName . There is another field, SectionID (Integer), that I want to sort by. I put $F{SectionID} in the Sort By Expression but I get the error: 1. Field not found : SectionID This field is in the dataset. I can add a group on this field and display it. When I try to use it in sorting I get the error. Is it possible to display one field in the column group header but sort by another? Thank you 回答1: Yes you need to