给定以下结果集:
---------------------------------------------------------
CustomerID Service TransType SubTotal Tax NetTotal
---------------------------------------------------------
106 A CREDIT 12.52 - 12.52
106 A CREDIT 10.07 - 10.07
106 B CREDIT 2.00 - 2.00
106 C REMOTE 5.99 - 5.99
106 C CREDIT 5.99 - 5.99
106 C CREDIT 3.99 0.30 3.69
106 C CREDIT 5.99 0.30 5.69
106 D CREDIT 5.99 - 5.99
---------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
请注意,NetTotal = SubTotal - Tax
请帮我计算总和(SubTotal),sum(Tax)和sum(NetTotal)以及pivotped TransType,如下所示:
--------------------------------------------------------------------------
CustomerID Service Cash Check Credit Remote SubTotal Tax NetTotal
--------------------------------------------------------------------------
106 A 0 0 …Run Code Online (Sandbox Code Playgroud) 在Windows Phone 7页面中,我有以下控件:
<controls:Pivot x:Name="Pivoter" Title="{Binding Name}"
TitleTemplate="{StaticResource PivotTitleTemplate}"
HeaderTemplate="{StaticResource PivotHeaderTemplate}"
ItemsSource="{Binding Items}"
ItemTemplate="{StaticResource DisplayItemDataTemplate}">
</controls:Pivot >
Run Code Online (Sandbox Code Playgroud)
使用此DataTemplate:
<DataTemplate x:Key="DisplayItemDataTemplate">
<Image Grid.Column="0" Stretch="Uniform"
Source="{Binding LargeImage, Converter={StaticResource UriBitmapConverter}}"/>
<StackPanel Grid.Column="1" Orientation="Vertical">
<HyperlinkButton NavigateUri="{Binding Uri}" Content="{Binding Uri}"/>
</StackPanel>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
这ItemsSource是一个ObservableCollection.当页面显示时,它会创建所有页面,PivotItems但第一个项目不会被创建,除非我向前滚动并返回它.它在滚动列表中有一个条目但没有PivotItem控件.
如果我在Pivot Control的LoadingPivotItem事件中设置了一个断点,那么在第一次显示数据时不会调用它,但是当我滚动并返回到第一个项目时,它只会被击中.
是否有人看到过类似的Pivot控件行为并有解决方法?或者我做错了什么?
我是PostgreSQL的新手.
假设我有一张桌子
colorname Hexa rgb rgbvalue
Violet #8B00FF r 139
Violet #8B00FF g 0
Violet #8B00FF b 255
Indigo #4B0082 r 75
Indigo #4B0082 g 0
Indigo #4B0082 b 130
Blue #0000FF r 0
Blue #0000FF g 0
Blue #0000FF b 255
Run Code Online (Sandbox Code Playgroud)
如果我在SQL Server中做一个Pivot
SELECT colorname,hexa,[r], [g], [b]
FROM
(SELECT colorname,hexa,rgb,rgbvalue
FROM tblPivot) AS TableToBePivoted
PIVOT
(
sum(rgbvalue)
FOR rgb IN ([r], [g], [b])
) AS PivotedTable;
Run Code Online (Sandbox Code Playgroud)
我把输出作为
colorname hexa r g b
Blue #0000FF 0 0 255
Indigo #4B0082 …Run Code Online (Sandbox Code Playgroud) SELECT * FROM EmployeeAttributes
PIVOT (
MAX(VALUE)
FOR AttributeID IN ([DD14C4C2-FC9E-4A2E-9B96-C6A20A169B2E],[BE8149E2-0806-4D59-8482-58223C2F1735],[23B2C459-3D30-41CA-92AE-7F581F2535D4])
) P
Run Code Online (Sandbox Code Playgroud)
结果
EmployeeID DD14C4C2-FC9E-4A2E-9B96-C6A20A169B2E BE8149E2-0806-4D59-8482-58223C2F1735 23B2C459-3D30-41CA-92AE-7F581F2535D4
------------------------------------ -------------------------------------------------- -------------------------------------------------- --------------------------------------------------
329999EA-6288-4E7D-87E8-12FF865AB301 Rauf 23 10
34E2B762-F065-42BB-B4D8-2252102F1C20 Amal NULL
5
Run Code Online (Sandbox Code Playgroud)
现在我如何在EmployeeID之后将列名更改为Name,Age,Salary?
尝试使用 pivot_longer。我不知道如何使用“names_sep”或“names_pattern”来解决这个问题。
dat <- tribble(
~group, ~BP, ~HS, ~BB, ~lowerBP, ~upperBP, ~lowerHS, ~upperHS, ~lowerBB, ~upperBB,
"1", 0.51, 0.15, 0.05, 0.16, 0.18, 0.5, 0.52, 0.14, 0.16,
"2.1", 0.67, 0.09, 0.06, 0.09, 0.11, 0.66, 0.68, 0.08, 0.1,
"2.2", 0.36, 0.13, 0.07, 0.12, 0.15, 0.34, 0.38, 0.12, 0.14,
"2.3", 0.09, 0.17, 0.09, 0.13, 0.16, 0.08, 0.11, 0.15, 0.18,
"2.4", 0.68, 0.12, 0.07, 0.12, 0.14, 0.66, 0.69, 0.11, 0.13,
"3", 0.53, 0.15, 0.06, 0.14, 0.16, 0.52, 0.53, 0.15, 0.16)
Run Code Online (Sandbox Code Playgroud)
所需的输出(宽数据的第一行)
group names values lower …Run Code Online (Sandbox Code Playgroud) 我是SQL的新手.我有一个包含不同考试数据的数据库,例如:
Student Test Grade
--------------------
St1 T1 A
St2 T1 B
St3 T1 B
St1 T2 B
St2 T2 B
St3 T2 A
St1 T3 A
St2 T3 C
St3 T3 B
Run Code Online (Sandbox Code Playgroud)
然后,我想使用测试(T1,T2和T3)作为列打印报告:
Student T1 T2 T3
----------------------
St1 A B A
St2 B B C
St3 B A B
Run Code Online (Sandbox Code Playgroud)
我尝试了不同的东西,但我不知道如何制作这样的打印输出.任何帮助表示赞赏!
假设我有一个假设的表格,以便某些游戏中的某些玩家得分时记录:
name points
------------
bob 10
mike 03
mike 04
bob 06
Run Code Online (Sandbox Code Playgroud)
如何获得每个玩家的分数总和并在一个查询中并排显示?
总积分表
bob mike
16 07
Run Code Online (Sandbox Code Playgroud)
我的(伪)查询是:
SELECT sum(points) as "Bob" WHERE name="bob",
sum(points) as "Mike" WHERE name="mike"
FROM score_table
Run Code Online (Sandbox Code Playgroud) 我发现setPivotX(也setPivotY)在Android中很奇怪.如果在视图的比例设置为1.00时设置了枢轴,则不会发生任何事情(只是枢轴更改).但是如果比例不等于1.0f(例如setScaleX(0.9f))并且您设置了枢轴,则视图会相对(?)移动到新的轴.这不奇怪吗?我知道水平和垂直位置(平移)与枢轴值无关,但为什么视图以1.0f以外的比例因子移动?
无论有没有缩放部分,请检查一下.
public class ScaleView extends View {
private final ScaleGestureDetector mScaleGestureDetector;
public ScaleView(Context context, AttributeSet attrs) {
super(context, attrs);
//setScaleX(0.9f);
//setScaleY(0.9f);
mScaleGestureDetector = new ScaleGestureDetector(context, new ScaleGestureDetector.OnScaleGestureListener() {
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
// does nothing intentionally
}
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
setPivotX(detector.getFocusX());
setPivotY(detector.getFocusY());
return true;
}
@Override
public boolean onScale(ScaleGestureDetector detector) {
return false;
}
});
}
@Override
public boolean onTouchEvent(MotionEvent event) {
mScaleGestureDetector.onTouchEvent(event);
return super.onTouchEvent(event);
}
}
Run Code Online (Sandbox Code Playgroud)
如何在枢轴更改之前设置视图的相同位置?
我有3个表,产品,图像和product_image.第三个是旋转表.除了PRODUCT_ID和image_id在product_image表,我也有在该转动表2个额外的字段:位置和类型,现在现有的产品型号A,我怎么把图像附A和设立,同时位置和该转轴记录中的类型值?谢谢.
我有下面的表格,我正在寻找枢轴,以便第1列中的描述成为新枢轴中的列标题.
Nominal Group | GrpID | Description | Value | CustomerID
---------------+-------+-----------------+-------------+-----------
Balance Sheet | 7 | BS description | 56973.10 | 2
Cost of Sales | 4 | COS description | 55950.17 | 2
Sales | 1 | Sales | -178796.18 | 2
Labour Costs | 5 | Wages | 18596.43 | 2
Overheads | 6 | Rent | 47276.48 | 2
Run Code Online (Sandbox Code Playgroud)
我正在使用下面的代码来获得下面的结果集:
select * from trialbalancegrouping
PIVOT (Sum(value)
for nominalgroupname in ([Sales],[Cost of Sales],[Labour Costs],[Overheads])) AS PVTtable
Run Code Online (Sandbox Code Playgroud)
- …
pivot ×10
sql ×3
sql-server ×2
aggregation ×1
android ×1
group-by ×1
laravel ×1
mysql ×1
postgresql ×1
r ×1
scale ×1
silverlight ×1
sqlite ×1
t-sql ×1
tidyverse ×1
view ×1