`

sybase cursor and report

阅读更多
select 1 as seq, a.*  into SelCommentaryList_jason from SelCommentaryList_terry_res1 a

declare cursor_t cursor
for
select sp_name,run_time,distance,counts from SelCommentaryList_jason order by run_time
go

declare @tmp int
declare @seq int
declare @sp_name varchar(200)
declare @run_time datetime
declare @distance int
declare @counts int
set @seq = 1
set @tmp=1

open cursor_t
fetch cursor_t into @sp_name,@run_time,@distance,@counts

WHILE @@sqlstatus = 0  
begin
    update SelCommentaryList_jason set seq = @seq where run_time = @run_time
   
    if @tmp%10 = 0
         set @seq = @seq + 1
    set @tmp = @tmp + 1
 
    fetch cursor_t into @sp_name,@run_time,@distance,@counts
end
close cursor_t
deallocate  cursor cursor_t

select sp_name, sum(c1) c1,sum(c2) c2,sum(c3) c3,sum(c4) c4,sum(c5)  c5,sum(c6) c6,sum(c7) c7,sum(c8) c8,sum(c9) c9,sum(c10) c10,sum(c11) c11,min(distance) minTime, max(distance) maxTime,avg(distance) avgTime, avg(counts) counts from
(
    select seq,sp_name,run_time,distance,counts,
    case when(seq = 1) then distance else 0 end as c1,
    case when(seq = 2) then distance else 0 end as c2,
    case when(seq = 3) then distance else 0 end as c3,
    case when(seq = 4) then distance else 0 end as c4,
    case when(seq = 5) then distance else 0 end as c5,
    case when(seq = 6) then distance else 0 end as c6,
    case when(seq = 7) then distance else 0 end as c7,
    case when(seq = then distance else 0 end as c8,
    case when(seq = 9) then distance else 0 end as c9,
    case when(seq = 10) then distance else 0 end as c10,
    case when(seq = 11) then distance else 0 end as c11
    from SelCommentaryList_jason
) b
group by sp_name
分享到:
评论

相关推荐

    sybase errors and troubleshooting Guide

    ### Sybase Adaptive Server Enterprise 错误与故障排除指南 #### 概述 Sybase Adaptive Server Enterprise(ASE)是一款高性能的企业级数据库管理系统,被广泛应用于多种关键业务环境之中。本指南旨在帮助用户理解...

    Sybase Performance and Tunning:Monitoring and Analyzing

    ### Sybase数据库性能优化:监控与分析 #### 一、引言 Sybase Adaptive Server Enterprise (ASE) 是一款高性能的企业级数据库管理系统,被广泛应用于多种关键业务应用中。随着业务的发展和技术的进步,对数据库的...

    Sybase Perfomance and Tuning:Basics

    本文将基于《Sybase Performance and Tuning:Basics》的内容,详细介绍Sybase数据库性能优化的基础知识。 #### 二、Sybase数据库简介 Sybase是由Sybase公司开发的一款关系型数据库管理系统,以其高可用性、高性能...

    sybase Performance and Tuning Guide

    ### Sybase SQL Server 性能与调优指南 #### 概述 《Sybase SQL Server 性能与调优指南》是一本专为Sybase SQL Server数据库管理员和技术人员设计的技术文档,旨在帮助用户理解并优化Sybase SQL Server的性能。...

    Sybase Performance and Tuning:locking

    ### Sybase数据库性能优化:锁定机制详解 #### 一、引言 在Sybase数据库管理系统中,锁定(Locking)是实现并发控制的关键技术之一。本文档基于Sybase Adaptive Server Enterprise 12.5.1版本,深入探讨了锁定机制...

    Sybase Performance and Tuning Series:Query Processing and Abstract Plans

    ### Sybase数据库性能与调优系列:查询处理与抽象计划 #### 一、引言 在Sybase数据库管理系统中,查询处理与优化是一项至关重要的任务,它直接影响到系统的整体性能和响应时间。本文档旨在深入探讨Sybase Adaptive...

    jTDS - SQL Server and Sybase JDBC driver 1.2.2 正式版(含源码)

    jTDS - SQL Server and Sybase JDBC driver 1.2.2 正式版 <br>一个Microsoft SQL Server数据库的Jdbc driver。开源的非常好用。 下载地址:http://jtds.sourceforge.net/<br><br><br>

    sybase ase for linux 12.5安装

    installation process covers the creation of a Sybase directory, setting up the user and group, unpacking and installing the software, configuring the server, and setting up the environment variables....

    Sybase Performance and Tuning:Optimizer and Abstract Plans

    ### Sybase数据库性能优化:优化器与抽象计划详解 #### 一、引言 Sybase Adaptive Server Enterprise (ASE) 是一款高性能的关系型数据库管理系统,在金融、电信等行业有着广泛的应用。随着业务规模的增长和技术的...

    Sybase IQ 官方文档(Sybase参考手册)

    **Sybase IQ官方文档概述** Sybase IQ是一款高效的数据仓库解决方案,专为大规模数据分析和决策支持而设计。作为Sybase公司的产品,它以其优秀的性能、可扩展性和对复杂查询的处理能力著称。本系列文档涵盖了从入门...

    sybase

    【Sybase 数据库简介】 Sybase 是一款由 Mark B. Hiffman 和 Robert Epstern 在1984年创立的公司所开发的数据库产品,自1987年起正式推出。Sybase 提供了多种操作系统环境下的版本,包括UNIX、Novell Netware 和 ...

    SybaseIQ_Architecture and Terminology IQ15

    ### Sybase IQ 15 架构与术语详解 #### Sybase IQ 概览 Sybase IQ 是一款高性能的企业级列式数据库管理系统,以其卓越的数据压缩技术和高效的查询处理能力著称于世。它专为数据仓库、商业智能及分析处理等应用场景...

    Sybase 使用指导手册Sybase 使用指导手册

    Sybase 使用指导手册详细介绍了如何在不同平台上安装、配置和管理 Sybase 数据库系统。Sybase 是一款强大的关系型数据库管理系统,广泛应用于企业级数据存储和处理。本手册旨在为用户提供全面的操作指南。 **第一章...

    sybase 客户端4sybase 客户端4

    sybase 客户端4sybase 客户端4sybase 客户端4sybase 客户端4sybase 客户端4sybase 客户端4sybase 客户端4sybase 客户端4sybase 客户端4sybase 客户端4sybase 客户端4sybase 客户端4

    sybase 客户端1 sybase 客户端1

    sybase 客户端1 sybase 客户端1 sybase 客户端1 sybase 客户端1 sybase 客户端1 sybase 客户端1 sybase 客户端1 sybase 客户端1 sybase 客户端1

    sybase 15.7 64位驱动,sybase数据源设置,sqlserver链接sybase设置

    在IT领域,数据库管理系统是核心组件之一,Sybase作为一个历史悠久且功能强大的关系型数据库系统,被广泛用于企业级应用。本篇文章将详细讲解Sybase 15.7 64位驱动的安装与配置,以及如何设置Sybase数据源和在SQL ...

    Sybase ASE 12.5 Performance and Tuning

    《Sybase ASE 12.5 Performance and Tuning》是一本深入探讨Sybase Adaptive Server Enterprise (ASE) 12.5版本性能管理和优化的专业书籍。本书由五位作者共同撰写:Jeffrey Garbus、Eric Miner、Joel DuPlessis、...

    sybase教程sybase教程

    在IT领域,Sybase是一种高性能、企业级的关系型数据库管理系统(RDBMS),由Sybase公司开发,后来被SAP收购。本教程将深入探讨Sybase的核心概念、安装配置、数据库管理、SQL语法以及实际应用。 一、Sybase概述 ...

    sybase 客户端2 sybase 客户端2

    sybase 客户端2sybase 客户端2sybase 客户端2sybase 客户端2sybase 客户端2sybase 客户端2

Global site tag (gtag.js) - Google Analytics