473,397 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

query problem (case when)

Hi all

i need one query help!

for reporting purpose i wrote one query - follows

select s.tran_empid as EmpId, e.M_EMPL_NAME as EmpName, p.PROJ_NAME as Project, t.TITL_NAME as Title,CASE WHEN s.tran_param='Project Level Key Initiatives' THEN round((sum(s.tran_revscore)/(s.tran_weightage/100))) END as PLKI,CASE WHEN s.tran_param='Quality' THEN round((sum(s.tran_revscore)/(s.tran_weightage/100))) END as Quality,CASE WHEN s.tran_param='Efficiency & Productivity' THEN round((sum(s.tran_revscore)/(s.tran_weightage/100))) END as Efficiency,CASE WHEN s.tran_param='Schedule Adherence' THEN round((sum(s.tran_revscore)/(s.tran_weightage/100))) END as Schedule,CASE WHEN s.tran_param='Skill Based' THEN round((sum(s.tran_revscore)/(s.tran_weightage/100))) END as Skill,CASE WHEN s.tran_param='Competency' THEN round((sum(s.tran_revscore)/(s.tran_weightage/100))) END as Competency,CASE WHEN s.tran_param='People Development' THEN round((sum(s.tran_revscore)/(s.tran_weightage/100))) END as Developement from tb_tran_storerating s, tb_mast_employee e, tb_master_project p, tb_master_title t where s.tran_empid=e.M_EMPL_ID_PK and s.tran_proj=p.PROJ_ID_PK and s.tran_title=t.TITL_ID_PK and tran_month='3' and tran_year='2007' and tran_empid in (select M_EMPL_ID_PK from tb_mast_employee where M_EMPL_PROJECT ='1') group by tran_empid, tran_param

it shows

output:
---------
empno empname quality plki ed
419 Vineeth null 3 null
419 Vineeth null null 3
419 Vineeth 4 null null
538 Peter 4 null null
538 Peter nulll 3 null
538 Peter null null 4


but i need following output

output:
---------
empno empname quality plki ed
419 vineeth 4 3 3
538 peter 4 3 4


please help meeeeeeeeeeeee..


thanks in advance

barrathi
Apr 26 '07 #1
1 1490
HAI ALL,

for reporting purpose i wrote one query - follows

select s.tran_empid as EmpId, e.M_EMPL_NAME as EmpName, p.PROJ_NAME as Project, t.TITL_NAME as Title,
CASE WHEN s.tran_param='Quality' THEN round((sum(s.tran_revscore)/(s.tran_weightage/100))) END as Quality,
CASE WHEN s.tran_param='Efficiency & Productivity' THEN round((sum(s.tran_revscore)/(s.tran_weightage/100))) END as Efficiency,
CASE WHEN s.tran_param='Skill Based' THEN round((sum(s.tran_revscore)/(s.tran_weightage/100))) END as Skill
from tb_tran_storerating s, tb_mast_employee e, tb_master_project p, tb_master_title t where s.tran_empid=e.M_EMPL_ID_PK and s.tran_proj=p.PROJ_ID_PK and s.tran_title=t.TITL_ID_PK and tran_month='3' and tran_year='2007' and tran_empid in (select M_EMPL_ID_PK from tb_mast_employee where M_EMPL_PROJECT ='1') group by tran_empid, tran_param

it shows

output:
---------
empno empname quality efficiency skill
419 Vineeth null 3 null
419 Vineeth null null 3
419 Vineeth 4 null null
538 Peter 4 null null
538 Peter nulll 3 null
538 Peter null null 4


but i need following output

output:
---------
empno empname quality efficency skill
419 vineeth 4 3 3
538 peter 4 3 4

HELP ME PLEASE..

thanks
barrathi
Apr 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Thomas R. Hummel | last post by:
Hi, I was just helping a coworker optimize a query. He had two versions: one which used UNION for each value for which he was tallying results and another query which used GROUP BY. Here is an...
9
by: wiredog | last post by:
I am struggling rewriting my query from MS Access' IIF, Then to SQL Servers TSQL language. I am hoping some one can give me some guidance. I believe I have the first portion of the query correct...
22
by: Robert Brown | last post by:
suppose I have the following table: CREATE TABLE (int level, color varchar, length int, width int, height int) It has the following rows 1, "RED", 8, 10, 12 2, NULL, NULL, NULL, 20...
7
by: jane | last post by:
HI, I was ask to do a query to get the member active condition I had table to show the member number and active status in three month. ACC A1 A2 A3 ---- -----------...
1
by: Stefan V. | last post by:
Hello! I am trying to convert a query written for SQL Server 2000 database tables, to a MS Access query. Here is what I have in SQL Server: SELECT t2.*, CASE WHEN t2.QType = '3' THEN...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
24
by: clare at snyder.on.ca | last post by:
I have a SQL query I need to design to select name and email addresses for policies that are due and not renewed in a given time period. The problem is, the database keeps the information for every...
10
by: Robert | last post by:
I am an attorney in a non-profit organization and a self-taught programmer. I'm trying to create a client db that will allow me to search for potential conflicts of interest based either on Social...
0
by: rashmigaikwad | last post by:
Hi All, I need help in optimizing the query mentioned below: SELECT SUM(CASE WHEN PROD_TYP='HBRMC' AND INC_MULTIPLE < 2.50 AND LTV <= 0.75 OR LTV IS NULL THEN ADV_IN_QTR ELSE 0 END) ...
1
by: Jimbo | last post by:
I have a query..if you look at the bottom of the where clause you'll see an "NOT IN" statement that is really hanging up the query..i'm trying to replace with a "NOT EXISTS" but it isnt appearing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.