pivot

Get a substring from a column and perform a groupBy and count

僤鯓⒐⒋嵵緔 提交于 2019-12-31 04:26:09
问题 I have a table that stores data about a large number of files, such as their language, unique ID, file path etc. I want to be able to get the sub-string from the unique ID which gives me the asset type, this is always the first 2 letters of the ID. I then want to group these asset types by language and have a count for how many of each type every language has. So at the end I would ideally like a table that has a language column and then a column for each substring (asset type). I have tried

SQL Server : Pivot Multiple Aggregates

不羁岁月 提交于 2019-12-31 04:19:04
问题 I have been looking for an answer for a few hours about my problem. My current table: StudentName Course Correct Wrong Blank Score ------------------------------------------------- Student1 Math 38 2 0 95 Student1 English 45 5 0 90 ... Student2 Math 38 2 0 95 Student2 English 45 5 0 90 What I want is: Math English StudentName Correct Wrong Blank Score Correct Wrong Blank Score Student1 38 2 0 95 45 5 0 90 Student2 38 2 0 95 45 5 0 90` ... SELECT dbo.tbl_Students.StudentName, dbo.tbl

Convert rows to columns oracle SQL

Deadly 提交于 2019-12-31 04:08:12
问题 I did not find any suitable previous answers hence posting the question. I need to convert rows to columns. The PIVOT examples all convert the rows to a single column whereas my requirement is multiple columns. My table looks like this Type ID test1 10 test1 20 test1 30 test2 10 test2 40 I would like it to be Type ID Type ID test1 10 test2 10 test1 20 test2 40 test1 30 Appreciate your suggestions/inputs! 回答1: You could enumerate rows with row_number() and make pivot : SQLFiddle demo select *

Pivoting a Table with Text and no Aggregation

青春壹個敷衍的年華 提交于 2019-12-31 01:51:29
问题 I've been looking through StackOverflow questions and haven't really found one for this issue. I have a table that's arranged basically like: Table.LineID Table.QuestionGroup Table.Question Table.Answer And I'd like to "pivot" the table, but the questions and answers don't have anything to aggregate. They're all just text fields for example, one might read: Table.LineID = 00001 Table.QuestionGroup = Color Table.Question = Outside Color Table.Answer = Dark Green Table.LineID = 00001 Table

Splitting/Pivot Data from a Date Range using SQL

孤街醉人 提交于 2019-12-30 14:15:16
问题 Hi I have a problem with regarding on split/pivot dates Here is my query select Name , Start , End from Employees where Start >= '1/27/2014' and End <= '1/31/2014' And Sample Data would be like this What I want to do is to split/pivot all data by date range like this But I don't know how can i do this and if it is possible? Thank you. 回答1: you need to generate all the dates. i did this here by using a cte. i then join this date range with your data and receive the sought result. with

Transpose Rows to Headers in MYSQL

冷暖自知 提交于 2019-12-30 11:54:48
问题 I'm trying to transpose a very basic output for use in a web application. As my strengths lie moreso in mysql, I'd like to this before it hits the app. What I currently have is: date value 2012-01-01 23 2012-01-02 33 2012-01-03 56 2012-01-04 10 What I want is: 2012-01-01 2012-01-02 2012-01-03 2012-01-04 23 33 56 10 My sql is: SELECT date, value from values where date >= curdate() - interval 3 day I've done a ton of research online and I can't figure out a good way to do this. This would need

2020即将到来,DevExpress WPF界面开发还有哪些功能值得期待?

江枫思渺然 提交于 2019-12-30 11:07:50
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 下载DevExpress v19.2完整版 通过 DevExpress WPF Controls ,您能创建有着强大互动功能的XAML基础应用程序,这些应用程序专注于当代客户的需求和构建未来新一代支持触摸的解决方案。 又到了每年发布DevExpress WPF产品线2020年非正式计划的时候了,关于DevExpress WPF 2020年您有哪些功能上的期待?欢迎在文章末尾留下您的建议,即将发布的新版可能有您想要拥有的功能哦~ WPF Pivot Grid 全新的过滤器面板 在为Data Grid和TreeList控件实现新的过滤器面板后,Pivot Grid也将启用它。全新的过滤器面板将为每个列包含带有单独过滤器的标记(而不是将整个筛选器字符串显示为纯文本)。 自定义表单搜索 Pivot Grid的自定义表单将显示一个搜索框,允许最终用户筛选可用字段的列表。 摘要过滤器弹出窗口 数据字段 标题将显示一个过滤器按钮,该按钮将调用一个弹出窗口,允许最终用户配置摘要过滤器。 摘要类型和组间隔的上下文菜单 全新的上下文菜单项允许最终用户在运行时更改摘要类型和组间隔。 WPF Data Editors 增强日期导航器 技术团队希望能够重写日期导航器可视化的部分,以便它可自定义和更轻便,同事还将介绍以下功能: 支持触摸

Select Rows As Column in SELECT [duplicate]

喜你入骨 提交于 2019-12-30 10:07:14
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: how to select columns as rows? I have a table with ID's, like Table ------- 1 2 3 4 5 and so on I have this query, SELECT A,B, Here I need To SELECT the Id's as Column , FROM MyTable So the Result of this will be, A B 1 2 3 4 5 6 7 and so on ----------------------------------- 回答1: You want a cross tab query. Check this out: http://www.simple-talk.com/sql/t-sql-programming/creating-cross-tab-queries-and-pivot

Retrieve ADO Recordset Field names (Classic ASP)

早过忘川 提交于 2019-12-30 06:11:11
问题 I wonder if someone can help: Long story short, I'm using MSSQL2005 to build a Pivot table. The data being examined is limited by date range (All data for 1 week starting from the nearest Monday to the date selected) When I run the Stored Proc and pass it a date, I get The correct table back eg: Time | 1 Jan 09 | 2 Jan 09 | 3 Jan 09 | ... 09:00 | 0 | 9 | 25 | ... 09:30 | 8 | 27 | 65 | ... 10:00 | 20 | 44 | 112 | ... (Apologies for the atrocious "table" formatting). The only problem I have is

PostgreSQL says “return and sql tuple descriptions are incompatible”

江枫思渺然 提交于 2019-12-30 04:28:09
问题 I have the following data: ID CLASS VALUE 1 NHB 700905.7243 1 HBW 164216.1311 1 HBO 700905.7243 2 NHB 146023.3792 2 HBW 89543.2972 2 HBO 82152.072 3 NHB 1409818.328 3 HBW 220430.7922 3 HBO 323512.9391 4 NHB 48711.3814 4 HBW 163385.1575 4 HBO 363352.3441 That I want to reorganize as: ID HBO HBW NHB 1 700905.7243 164216.1311 700905.7243 2 82152.072 89543.2972 146023.3792 3 323512.9391 220430.7922 1409818.328 4 363352.3441 163385.1575 48711.3814 Please note that the values in columns HBW, HBO