Sql Sybase Ase Alternative Way to Support Lead/Lag Function

There is audit trial requirement that need to be captured into log table these day. But we suffer from the limited function provided by Sybase ASE DB in order to achieve our goals. SybaseASE 12.5 does not support neither analytic function nor row number column, and therefore we have to implement cross comparison by ourselves via basic semantics.

1
2
3
4
5
6
7
8
9
10
11
--create rownum column
select rownum = identity(10), * from #temp_table from table where 1=2
insert into #temp_table
select * from table where pid = @pid
insert into #temp_table
select * from table_history where pid = @pid order by audit_update_date desc
--use self-join to match the cross rows
select a.rownum,
case when a.col1 = b.col1 then 'equal' else 'inequal' end
from #temp_table a left out join #temp_table b on ( a.pid = b.pid and (a.rownum + 1) = b.rownum )
where ...

In contrast, we also provide oracle version of implementation.

Sql Switch/Transpose Columns and Rows

In practice, we will meet the requirement to rotate the table including convert cols to rows, convert rows to cols. In this session, I'll produce the solution in common method as well as db-specified features.

Convert columns to rows

1
2
3
4
5
6
7
8
9
10
--common solution
select * from (
select id, 'col_1' as col_name, col_1 as col_val
from table
union all
select id, 'col_2' as col_name, col_2 as col_val
from table
union all
...
) order by id
1
2
3
4
5
6
7
--oracle 11g unpivot query
select *
from table
unpivot (
col_val for col_name in (col_1 as 'col_1', col_2 as 'col_2')
)
order by id

Concert rows to columns

1
2
3
4
5
6
7
--common solution
select id,
max(case when col_name = 'col_1' then col_val else null end) as col_1,
max(case when col_name = 'col_2' then col_val else null end) as col_2,
...
from table
order by id
1
2
3
4
5
6
7
8
--oracle 11g pivot query
select *
from table
pivot (
max(col_val) for col_name in ('col_1' as col_1,'col_2' as col_2)
)
where ...
order by id

Excel pivot table

For non-sql approaches, we can use excel pivot table. Excel spreadsheets are a great way to pivot and analyze Oracle data, and tools.

Operating System Concepts Terminology

The aim of this post is to review the crucial terms of operating-system and basic interaction of these underlying components.

Before starting with topic, I am going to reveal why I try to read books of OS related at this point. Let me conclude the reasons, first and foremost, various applications in my daily work encounter issues that are associated with LINUX system, such as buffer size, open file limits and unable to create native threads etc. All of these issues point out to the knowledge of OS. Next, Java performance tuning is always based on the operating system concept, like memory management, cpu utilization etc. Furthermore, including all the design concepts are derived from the solution of common issue inside operating system.

Due to these, it is so encouraged to read and go through operating system concept again that I could be inspired and get everything tied. If there are any findings or association with Java, I will make more explanations and comments linked with definitive resource.

Read More

First Post

MarkDown Template

Blockquotes

Header inside blockquote

  1. This is the first list item.
  2. This is the second list item.

This is nested blockquote.

Here's some example code:

return shell_exec("echo $input | $markdown_script");

List

Markdown supports ordered (numbered) and unordered (bulleted) lists. Unordered lists use asterisks, pluses, and hyphens — interchangably — as list markers:

  • Red
  • Green
  • Blue

  • Bird

  • McHale
  • Parish

To put a code block within a list item, the code block needs to be indented twice — 8 spaces or two tabs:

  • A list item with a code block:
      <codes goes here with two leading tabs>
    

Code Blocks

To produce a code block in Markdown, simply indent every line of the block by at least 4 spaces or 1 tab. For example, given this input:

Horizontal Rules






This is an example inline link. See my About page for details.

This is an example reference-style link.

I get 10 times more traffic from Google than from Yahoo or MSN.

Emphasis

single asterisks

single underscores

double asterisks

double underscores

unfriggingbelievable

*this text is surrounded by literal asterisks*

Code

Use the printf() function. There is a literal backtick (`) here. Please don't use any <blink> tags.

Images

Alt text

Alt text

Miscellaneous

http://daringfireball.net/projects/markdown/syntax#em address@example.com

Blackslash escapes

\   backslash
`   backtick
*   asterisk
_   underscore
{}  curly braces
[]  square brackets
()  parentheses
#   hash mark
+   plus sign
-   minus sign (hyphen)
.   dot
!   exclamation mark
This is an H6