在水平视图中获取信息 [英] Get Information In Horizontal View

查看:60
本文介绍了在水平视图中获取信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个查询,其中我想在水平行中显示记录,例如

I have an query in which i want to show records in horizntal rows for eg.

select count(*) from registration where joiningdate between '01-sep-2011' and '10-sep-2011'  
union   
select  count(*) from registration where joiningdate between '01-sep-2011' and '10-sep-2011' and product_receipt is null

推荐答案

通常,格式化不应该使用SQL. SQL的目的是获取和操作数据,而不是对其进行格式化.格式化应在客户端的应用程序中调用数据库.
Typically formatting shouldn''t be done with SQL. The purpose of SQL is to fetch and manipulate data, not to format it. Formatting should be done on the client side, in the application calling the database.


尝试一下,希望对您有所帮助.

try this,hope it will help you.

with a as
 (
 select row_number() over(order by (select 1)) as rownumber,id,view1 from heview --here ur table name and column names ie id.. 
 ),
 b as
 (
   select row_number() over(order by (select 1)) as rownumber,id,view1 from  a where rownumber%2 <>0
 ),
 c as
 (
   select row_number() over(order by (select 1)) as rownumber,id,view1 from  a where rownumber%2 =0
 )
select c.id,c.view1,b.id,b.view1 from b,c where b.rownumber=c.rownumber


也许您可以使用案例陈述

选择count(*)总计,
Sum(如果product_receipt为Null,则为1的情况
其他0
结束)Total_Receipt_Null
从注册
凡加入日期
在"2011年9月1日"和"2011年9月10日"之间
Maybe you can use case statment

select count(*) Total,
Sum( Case When product_receipt Is Null then 1
Else 0
End) Total_Receipt_Null
From registration
Where joiningdate
between ''01-sep-2011'' and ''10-sep-2011''


这篇关于在水平视图中获取信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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