Sponsored Content
Top Forums Programming DB2 Query to pick hierarchy values Post 303021994 by Peasant on Wednesday 22nd of August 2018 08:03:18 AM
Old 08-22-2018
Check if this fills your requirement :
Code:
select * from testing ;
Ramesh|10|MANAGER
Ramesh|11|INTERVIEWER
Anand|11|INTERVIEWER
Anand|10|MANAGER
kits|11|INTERVIEWER
Peasant|12|EMPLOYEE
Terminator|5|MACHINE
Terminator|10|MANAGER

select * from testing order by (
    case role_name

    when 'MANAGER'
    then 1

    when 'INTERVIEWER'
    then 2

    when 'MACHINE'
    then 3

    when 'EMPLOYEE'
    then 4

    end
) asc;
Ramesh|10|MANAGER
Anand|10|MANAGER
Terminator|10|MANAGER
Ramesh|11|INTERVIEWER
Anand|11|INTERVIEWER
kits|11|INTERVIEWER
Terminator|5|MACHINE
Peasant|12|EMPLOYEE

Regards
Peasant

Last edited by Peasant; 08-22-2018 at 09:07 AM.. Reason: Changed case to uppercase input.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pick values from column based on key values by usin AWK

Dear Guyz:) I have 2 different input files like this. I would like to pick the values or letters from the inputfile2 based on inputfile1 keys (A,F,N,X,Z). I have done similar task by using awk but in that case the inputfiles are similar like in inputfile2 (all keys in 1st column and values in... (16 Replies)
Discussion started by: repinementer
16 Replies

2. Shell Programming and Scripting

pad db2 query result to 8 bits

Hi , I am using a db2 query to get the maximum sequence number from a field.Now this value is taking up only 2 places.(i.e its less than 100).It can grow up to 3 places later but me requirement is that when i write it in a text file, it should be padded upto 8 places. Please help (1 Reply)
Discussion started by: lifzgud
1 Replies

3. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

4. Shell Programming and Scripting

Db2 query with script

Hi All, I want to connect two tables in DB2 using shell script and then compare the contents of two tables field by field.and i should return on the screen the un matched records .. Could any one please help me in connecting database tables using Unix and retriving data from the same. (1 Reply)
Discussion started by: kanakaraju
1 Replies

5. AIX

DB2 user query utilization?

I am new to AIX, but not new to the UNIX world. Recently I got a request to come with some kind of report to do the following: report if user query is using > 70% CPU (within DB2) > 5 minutes. I am by no means a DB2 guru so I do not know how to get that from within it, so I was wondering if there... (4 Replies)
Discussion started by: savigabi
4 Replies

6. Shell Programming and Scripting

Return db2 query value to shell script

Hi, Im new to DB2. I need to connect to DB2 from shell script and return the query output back to shell script variable. this is my code #!/bin/ksh db_name=db db_user=usr db_pwd=pwd db2 <<EOSQL connect to $db_name user $db_user using "$db_pwd" select count(1) from table quit EOSQL ... (3 Replies)
Discussion started by: sup
3 Replies

7. Shell Programming and Scripting

awk file to read values from Db2 table replacing hard coded values

Hi, I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below... if (start_new_rec=="true"){ exclude_user="false"; user=toupper($6); match(user, "XXXXX."); if (RSTART ==2 ) { ... (9 Replies)
Discussion started by: asandy1234
9 Replies

8. Shell Programming and Scripting

Db2 query on other host

Hello, i need some help with a script. I made a script, which connect to different hosts to get some informations. But i got now some problems with getting informations of a database (db2) which is on a other host. I tried something like var=$(rsh HOST su - db2adm -c "db2 connect to database;... (2 Replies)
Discussion started by: Cyver
2 Replies

9. Programming

DB2 Query -Convert multi values from column to rows

Hi Team I am using DB2 artisan tool and struck to handle multi values present in columns that are comma(,) separated. I want to convert those column values in separate rows . For example : Column 1 Column2 Jan,Feb Hold,Sell,Buy Expected Result Column1 ... (3 Replies)
Discussion started by: Perlbaby
3 Replies

10. UNIX for Beginners Questions & Answers

DB2 Query modification to remove duplicate values using LISTAGG function

I am using DB2 v9 and trying to get country values in comma seperated format using below query SELECT distinct LISTAGG(COUNTRIES, ',') WITHIN GROUP(ORDER BY EMPLOYEE) FROM LOCATION ; Output Achieved MEXICO,UNITED STATES,INDIA,JAPAN,UNITED KINGDOM,MEXICO,UNITED STATES The table... (4 Replies)
Discussion started by: Perlbaby
4 Replies
UPDATE-MANAGER(8)                                             System Manager's Manual                                            UPDATE-MANAGER(8)

NAME
update-manager - graphical management of software packages updates SYNOPSIS
update-manager [options] DESCRIPTION
Update-manager is a frontend for the apt package management system. It allows you to perform some actions of the command line tool apt-get in a graphical environment. Update-manager is especially designed for upgrading your system, or migrating your system towards a more recent version. OPTIONS
For a daily use, you may launch update-manager with no options so that your system is just upgraded. For migration purposes, update-manager accepts some options: -h, --help Show a similar help message -c, --check-dist-upgrades Check if a new distribution release is available -d, --devel-release Check if upgrading to the latest devel release is possible -p, --proposed Try to run a dist-upgrade --dist-upgrade Try to run a dist-upgrade ACTIONS PERFORMED DURING AN UPGRADE TO A NEW VERSION
* eventually reinstall the package ubuntu-desktop * switch to an updated sources.list entries * adds the default user to new groups if needed SEE ALSO
Synaptic, sources.list, aptitude AUTHORS
update-manager was developed by Michael Vogt <mvo@ubuntu.com> with various contributors (see AUTHORS file) This manual page was originally written by Bruno Mangin and Michael Vogt <mvo@ubuntu.com>. COPYRIGHT
Copyright (C) 2006-2007 Canonical There is NO warranty. You may redistribute this software under the terms of the GNU General Public License. For more information about these matters, see the files named COPYING. August 2, 2007 UPDATE-MANAGER(8)
All times are GMT -4. The time now is 01:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy