将行转换为列 [英] convert the rows as columns

查看:155
本文介绍了将行转换为列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi ..
我有3张桌子,如下面的波纹管所示

签到
ID RoomId ComingForm
1 1海得拉巴
2 2海得拉巴
3 3海得拉巴
4 3钦奈
6 2钦奈
7 1钦奈
8 3钦奈

房间
ID RoomName RoomClassId
1 101 2
2 102 2
3103 1

RoomClass
ID RoomClassName
1豪华
2普通


结果将是
CommingForm Luxury Narmal
海得拉巴2 1
钦奈2 2

这些是海得拉巴人等占领的豪华客房的数量.

请帮助我...

hi..
i have a 3 table like as shown in bellow

CheckIn
ID RoomId ComingForm
1 1 Hyderabad
2 2 Hyderabad
3 3 Hyderabad
4 3 Chennai
6 2 Chennai
7 1 Chennai
8 3 Chennai

Room
ID RoomName RoomClassId
1 101 2
2 102 2
3 103 1

RoomClass
ID RoomClassName
1 Luxury
2 Normal


Result will be
CommingForm Luxury Narmal
Hyderabad 2 1
Chennai 2 2

these are the count of luxury rooms occupied by the Hyderabad people etc..

plz help me...

推荐答案

您可以在数据库中的查询中执行此操作.为此创建一个存储过程,并使用在我的文章中找到的信息在SQL Server 2005中使用多维数据集和事件处理程序进行动态透视,2008和2008 R2 [ ^ ].
您所需要做的就是调用存储过程,并从数据库中读取数据集/数据表.

使LINQ调用存储过程为: ^ ]
you can do this in a query in the database. Create a stored procedure for it and use the information you can find in my article Dynamic Pivoting with Cubes and eventhandlers in SQL Server 2005, 2008 and 2008 R2[^].
All you have to do is call the stored procedure and read the dataset/datatable from your database.

to have LINQ call a stored procedure read: http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx[^]


这篇关于将行转换为列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆