db2

Side-by-side comparison of data by year in SQL

喜欢而已 提交于 2019-12-06 01:53:36
I have table similar to the following: Year | Product | Value 2006 A 10 2006 B 20 2006 C 30 2007 A 40 2007 B 50 2007 C 60 I would like a query that would return the following comparison Product | 2006 Value | 2007 Value A 10 40 B 20 50 C 30 60 What are the options to do so? Can it be done without joins? I'm working with DB2, but answers in all SQL types would be helpful. select Product, max(case when Year = 2006 then Value end) as [2006 Value], max(case when Year = 2007 then Value end) as [2007 Value] from MyTable group by Product order by Product A simple cross tab query should do it SELECT

How to extract numerical data from SQL result

独自空忆成欢 提交于 2019-12-06 01:46:53
Suppose there is a table "A" with 2 columns - ID (INT), DATA (VARCHAR(100)). Executing "SELECT DATA FROM A" results in a table looks like: DATA --------------------- Nowshak 7,485 m Maja e Korabit (Golem Korab) 2,764 m Tahat 3,003 m Morro de Moco 2,620 m Cerro Aconcagua 6,960 m (located in the northwestern corner of the province of Mendoza) Mount Kosciuszko 2,229 m Grossglockner 3,798 m // the DATA continues... --------------------- How can I extract only the numerical data using some kind of string processing function in the SELECT SQL query so that the result from a modified SELECT would

Why is DB2 Type 4 JDBC Driver looking for native library db2jcct2?

隐身守侯 提交于 2019-12-06 01:29:59
问题 I thought the Type 4 JDBC driver was pure Java and wouldn't require native libraries. When I put db2jcc4.jar in the WEB-INF/lib directory of my Tomcat app packaged as a .war file, I get the following error when attempting to use the app: Got SQLException: com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][4.12.55] Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError The relevant application code is as follows and the exception is thrown due to the last line in the

How to get DB2 MQT last refresh time

风格不统一 提交于 2019-12-06 01:04:52
For a DB2 on z/OS Materialized Query Table, how can you retrieve the last refresh time? The documentation states that one of the actions that DB2 takes during a REFRESH is to populate the catalog with a refresh timestamp. Updates the DB2 catalog with a refresh timestamp and the cardinality of the materialized query table What catalog table and column holds this information? I was looking for this in order to compare the time stamp with another resource to see if it has changed since the last refresh. If the other resource has changed since the last refresh, the MQT must be refreshed. You can

DB2中字符、数字和日期类型之间的转换

浪子不回头ぞ 提交于 2019-12-06 00:12:20
DB2中字符、数字和日期类型之间的转换 一般我们在使用DB2或Oracle的过程中,经常会在数字<->字符<->日期三种类 型之间做转换,那么在DB2和Oracle中,他们分别是如何实现的呢?在Oracle这几个类型之间的转换是十分方便的,通过 to_char|to_date|to_number函数即可完成类型转换。本小节主要介绍DB2中的一些知识,从Oracle转过来的DBA或开发人 员,可以对比着 学习 。 数字型到字符型的转换 DB2中的col_a字段 字段类型 到字符类型的转换 smallint char(col_a) integer bigint double char(cast(col_a as decimal(8,2)))) decimal(8,2) Digits(col_a) 测试 一下: SQL> create table test_datatype SQL> ( SQL> col_a smallint, SQL> col_b integer, SQL> col_c bigint, SQL> col_d decimal(8,2), SQL> col_e double SQL> ); DB20000I SQL 命令成功完成。 SQL> insert into test_datatype values(1,20,3000,4000.44,55555);

Tie the life of a process to the shell that started it

房东的猫 提交于 2019-12-05 23:05:46
问题 In a UNIX-y way, I'm trying to start a process, background it, and tie the lifetime of that process to my shell. What I'm talking about isn't simply backgrounding the process, I want the process to be sent SIGTERM, or for it to have an open file descriptor that is closed, or something when the shell exits, so that the user of the shell doesn't have to explicitly kill the process or get a "you have running jobs" warning. Ultimately I want a program that can run, uniquely, for each shell and

DB2 - How to run an ad hoc select query with a parameter in IBM System i Access for Windows GUI Tool

我怕爱的太早我们不能终老 提交于 2019-12-05 22:45:56
I would like to run some ad hoc select statements in the IBM System I Navigator tool for DB2 using a variable that I declare. For example, in the SQL Server world I would easily do this in the SQL Server Management Studio query window like so: DECLARE @VariableName varchar(50); SET @VariableName = 'blah blah'; select * from TableName where Column = @VariableName; How can I do something similar in the IBM System I Navigator tool? Brian I ran across this post while searching for the same question. My coworker provided the answer. It is indeed possible to declare variables in an ad hoc SQL

Spring 3 The matching wildcard is strict, but no declaration can be found for element 'jee:jndi-lookup'

那年仲夏 提交于 2019-12-05 21:15:12
问题 So I am having an issue similar to here... Spring 3.0 Error: The matching wildcard is strict, but no declaration can be found for element my pom looks like this <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc"

Mapping a table called “group” in Hibernate for DB2 and HSQLDB

柔情痞子 提交于 2019-12-05 20:52:52
I have a table called group , that I am trying to map using hibernate for DB2 and HSQLDB . Table name group is a reserved word and it must be quoted in HSQLDB. However DB2 does not like quoted table name. So this mapping works in HSQLDB but not in DB2: @Entity @Table(name="`group`") public class Group { Mapping results in following error in DB2 (making a query that involves Group table): Caused by: com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -204, SQLSTATE: 42704, SQLERRMC: SCHEMA_NAME.group at com.ibm.db2.jcc.b.hh.c(hh.java:1662) at com.ibm.db2.jcc.b.hh.d(hh.java:1650) at com.ibm

PostgreSQL DISTINCT用法

♀尐吖头ヾ 提交于 2019-12-05 20:37:22
PostgreSQL的DISTINCT关键字用于与SELECT语句消除所有重复的记录,并获取唯一记录。有可能的情况下,当你有多个重复的表中的记录。虽然取这样的记录,它更有意义,获取唯一的记录,而不是获取重复记录。 语法: DISTINCT关键字消除重复记录的基本语法如下: SELECT DISTINCT column1, column2,.....columnN FROM table_name WHERE [condition] 案例: 1、去重;关键字distinct去重功能 在其他数据库(oracle、mysql、db2、informix)也有。 select distinct idfa from nlogs where recvtime>='2015-09-01 00:00:00' and recvtime<'2015-09-03 00:00:00'; 2、统计不重复个数 select count( distinct ( idfa ) ) from nlogs where recvtime>='2015-09-01 00:00:00' and recvtime<'2015-09-03 00:00:00'; 额外: distinct跟on一起用; 使用DISTINCT ON实现用窗口函数实现的取第一名的功能,这个功能oracle,mysql是没有的