将矩阵查询绑定到任何数据工具(例如gridview,repeater等)中 [英] bind matrix query into any datatools like gridview,repeater etc

查看:40
本文介绍了将矩阵查询绑定到任何数据工具(例如gridview,repeater等)中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用诸如gridview,repeater等的任何数据工具绑定矩阵数据.
我的问题是,我有如下所示的sql输出(使用查询)

how can i bind matrix data using any datatools like gridview,repeater etc.
My problem is,I have a sql-output like below(Using Query)

Monthid   month  head  amount
 6        june   DA    100
 6        june   TA    110
 6        june   HRA   330
 8        Aug    DA    210
 8        Aug    TA    620
 8        Aug    HRA   510
 1        jan    DA    250
 1        jan    TA    320
 1        jan    HRA   320



我想在datacontrol中显示它,如下所示



i want to display it in datacontrol like below

month  DA   TA   HRA

Jan    250  320  320
June   100  110  330
Aug    210  620  510

推荐答案

尝试这个实际上我还没有测试过,但是您会发现逻辑.
try this actually i have not tested it but you will get logic.
select A.month ,
 (select B.amount where B.monthid=A.monthid and B.head='DA') as 'DA',
 (select B.amount where B.monthid=A.monthid and B.head='TA') as 'TA',
(select B.amount where B.monthid=A.monthid and B.head='HRA') as 'HRA'
from tablename A
inner join tablename  B on
A.monthid= b.monthid


这篇关于将矩阵查询绑定到任何数据工具(例如gridview,repeater等)中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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