473,698 Members | 2,883 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

query problem (case when)

29 New Member
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='P roject Level Key Initiatives' THEN round((sum(s.tr an_revscore)/(s.tran_weighta ge/100))) END as PLKI,CASE WHEN s.tran_param='Q uality' THEN round((sum(s.tr an_revscore)/(s.tran_weighta ge/100))) END as Quality,CASE WHEN s.tran_param='E fficiency & Productivity' THEN round((sum(s.tr an_revscore)/(s.tran_weighta ge/100))) END as Efficiency,CASE WHEN s.tran_param='S chedule Adherence' THEN round((sum(s.tr an_revscore)/(s.tran_weighta ge/100))) END as Schedule,CASE WHEN s.tran_param='S kill Based' THEN round((sum(s.tr an_revscore)/(s.tran_weighta ge/100))) END as Skill,CASE WHEN s.tran_param='C ompetency' THEN round((sum(s.tr an_revscore)/(s.tran_weighta ge/100))) END as Competency,CASE WHEN s.tran_param='P eople Development' THEN round((sum(s.tr an_revscore)/(s.tran_weighta ge/100))) END as Developement from tb_tran_storera ting s, tb_mast_employe e e, tb_master_proje ct p, tb_master_title t where s.tran_empid=e. M_EMPL_ID_PK and s.tran_proj=p.P ROJ_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_employe e 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 1499
barrathi
29 New Member
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='Q uality' THEN round((sum(s.tr an_revscore)/(s.tran_weighta ge/100))) END as Quality,
CASE WHEN s.tran_param='E fficiency & Productivity' THEN round((sum(s.tr an_revscore)/(s.tran_weighta ge/100))) END as Efficiency,
CASE WHEN s.tran_param='S kill Based' THEN round((sum(s.tr an_revscore)/(s.tran_weighta ge/100))) END as Skill
from tb_tran_storera ting s, tb_mast_employe e e, tb_master_proje ct p, tb_master_title t where s.tran_empid=e. M_EMPL_ID_PK and s.tran_proj=p.P ROJ_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_employe e 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
2446
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 aproximation of what they were: Query #1: --------- SELECT 12 AS ,
9
2286
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 but do believe this requires a "NESTED" argument. This is where I am lost. My Original MS ACCESS Query reads-- SELECT DISTINCTROW REGION_TRAFIC.*, IIf(Mid(,5,2)=,
22
3045
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 3, NULL, 9, 82, 25
7
2050
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 ---- ----------- ----------- ----------- c001 1 1 1
1
5329
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 t1.Note ELSE CASE WHEN t2.QType = '2' THEN CASE WHEN CONVERT(varchar(100), t1.ANumber) = '1' THEN 'Yes' ELSE 'No' END ELSE CASE WHEN CONVERT(varchar(5), t2.Qnumber)+'.' +
6
4843
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 SalesManName AT Alan Time
24
19905
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 renewal in the history of the policyholder. The information is in 2 tables, policy and customer, which share the custid data. The polno changes with every renewal Renewals in 2004 would be D, 2005 S, and 2006 L. polexpdates for a given customer...
10
2100
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 Security # or on Last Name. I've created two different tables with the following fields in each table: ClientInfo Client# (primary key) First Name Middle Name Last Name
0
2141
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) HBRMC_2p5, SUM(CASE WHEN PROD_TYP='HBNMC' AND INC_MULTIPLE < 2.50 AND LTV <= 0.75 OR LTV IS NULL THEN ADV_IN_QTR ELSE 0 END) HBNMC_2p5, SUM(CASE WHEN PROD_TYP='HBOS' AND INC_MULTIPLE < 2.50 AND LTV <= 0.75 OR LTV IS NULL THEN ADV_IN_QTR ELSE 0...
1
4218
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 to work...I need to get a result set where the email address of the outter most query is not in that sub query...thanks: -->Code Begins Here SELECT DISTINCT
0
8683
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7740
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.