473,399 Members | 3,401 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,399 software developers and data experts.

How to insert a space after each Manager Starts.

hi,
guys
i have query which given below output given below

manager personlevel person name
2085 1 Howard Wilson1
2085 2 Howard Wilson2
2085 3 Howard Wilson3
2085 4 Howard Wilson4
2085 5 Howard Wilson5
6086 1 Andrew Saxon
6086 2 Andrew Saxon
6086 3 Ian Thompson
6086 4 Ian Thompson
6086 5 Phil Dargan

what i want is after a manager ends i want a null to be inserted for
each of there columns
so that i can distinguish that when a new manager starts

so thatt output looks like this

manager personlevel person name
2085 1 Howard Wilson1
2085 2 Howard Wilson2
2085 3 Howard Wilson3
2085 4 Howard Wilson4
2085 5 Howard Wilson5
null null null
6086 1 Andrew Saxon
6086 2 Andrew Saxon
6086 3 Ian Thompson
6086 4 Ian Thompson
6086 5 Phil Dargan

Brlliant minds any solution for this..
i know can i loop through the records and do it
and check for a new manager
but i want a better solution ..
give me your ideads folks..

Regards,
Navin Mahindroo
Jul 20 '05 #1
3 2296
Hi

You don't post the DDL or the current query so it is hard to know what your
SQL is.

Assuming something like:

SELECT Manager, Personlevel, PersonName from Mgmt

You could try (untested)

SELECT Manager, Personlevel, PersonName from
( SELECT Manager as Id, Manager, Personlevel, PersonName from Mgmt
UNION
SELECT DISTINCT Manager, NULL, NULL, NULL from Mgmt
ORDER BY Id ASC, Manager DESC ) M

John

"Navin" <na******@rediffmail.com> wrote in message
news:5d**************************@posting.google.c om...
hi,
guys
i have query which given below output given below

manager personlevel person name
2085 1 Howard Wilson1
2085 2 Howard Wilson2
2085 3 Howard Wilson3
2085 4 Howard Wilson4
2085 5 Howard Wilson5
6086 1 Andrew Saxon
6086 2 Andrew Saxon
6086 3 Ian Thompson
6086 4 Ian Thompson
6086 5 Phil Dargan

what i want is after a manager ends i want a null to be inserted for
each of there columns
so that i can distinguish that when a new manager starts

so thatt output looks like this

manager personlevel person name
2085 1 Howard Wilson1
2085 2 Howard Wilson2
2085 3 Howard Wilson3
2085 4 Howard Wilson4
2085 5 Howard Wilson5
null null null
6086 1 Andrew Saxon
6086 2 Andrew Saxon
6086 3 Ian Thompson
6086 4 Ian Thompson
6086 5 Phil Dargan

Brlliant minds any solution for this..
i know can i loop through the records and do it
and check for a new manager
but i want a better solution ..
give me your ideads folks..

Regards,
Navin Mahindroo

Jul 20 '05 #2
Hi Navin M,

Same other way round.
SELECT 'N' 'GRP_SEP',manager, personlevel ,[person name] FROM
TableName
UNION ALL
SELECT DISTINCT 'Y',manager,NULL,NULL FROM TableName
ORDER BY manager,GRP_SEP ASC

Group seperator is added to explicitly know that row with 'Y' is group
seperator and avoid null conflit if personlevel and name both are
null.

Also note that Manager field has appropriate index on it.

hope this helps you.

Thanks Amit.



na******@rediffmail.com (Navin) wrote in message news:<5d**************************@posting.google. com>...
hi,
guys
i have query which given below output given below

manager personlevel person name
2085 1 Howard Wilson1
2085 2 Howard Wilson2
2085 3 Howard Wilson3
2085 4 Howard Wilson4
2085 5 Howard Wilson5
6086 1 Andrew Saxon
6086 2 Andrew Saxon
6086 3 Ian Thompson
6086 4 Ian Thompson
6086 5 Phil Dargan

what i want is after a manager ends i want a null to be inserted for
each of there columns
so that i can distinguish that when a new manager starts

so thatt output looks like this

manager personlevel person name
2085 1 Howard Wilson1
2085 2 Howard Wilson2
2085 3 Howard Wilson3
2085 4 Howard Wilson4
2085 5 Howard Wilson5
null null null
6086 1 Andrew Saxon
6086 2 Andrew Saxon
6086 3 Ian Thompson
6086 4 Ian Thompson
6086 5 Phil Dargan

Brlliant minds any solution for this..
i know can i loop through the records and do it
and check for a new manager
but i want a better solution ..
give me your ideads folks..

Regards,
Navin Mahindroo

Jul 20 '05 #3
Hi

Got around to testing it.... you can't use the order by in the derived
table!

SELECT Manager, Personlevel, PersonName from
( SELECT Manager as Id, Manager, Personlevel, PersonName from Mgmt
UNION
SELECT DISTINCT Manager, NULL, NULL, NULL from Mgmt
) M
ORDER BY id, Manager Desc

John

"John Bell" <jb************@hotmail.com> wrote in message
news:3f***********************@reading.news.pipex. net...
Hi

You don't post the DDL or the current query so it is hard to know what your SQL is.

Assuming something like:

SELECT Manager, Personlevel, PersonName from Mgmt

You could try (untested)

SELECT Manager, Personlevel, PersonName from
( SELECT Manager as Id, Manager, Personlevel, PersonName from Mgmt
UNION
SELECT DISTINCT Manager, NULL, NULL, NULL from Mgmt
ORDER BY Id ASC, Manager DESC ) M

John

"Navin" <na******@rediffmail.com> wrote in message
news:5d**************************@posting.google.c om...
hi,
guys
i have query which given below output given below

manager personlevel person name
2085 1 Howard Wilson1
2085 2 Howard Wilson2
2085 3 Howard Wilson3
2085 4 Howard Wilson4
2085 5 Howard Wilson5
6086 1 Andrew Saxon
6086 2 Andrew Saxon
6086 3 Ian Thompson
6086 4 Ian Thompson
6086 5 Phil Dargan

what i want is after a manager ends i want a null to be inserted for
each of there columns
so that i can distinguish that when a new manager starts

so thatt output looks like this

manager personlevel person name
2085 1 Howard Wilson1
2085 2 Howard Wilson2
2085 3 Howard Wilson3
2085 4 Howard Wilson4
2085 5 Howard Wilson5
null null null
6086 1 Andrew Saxon
6086 2 Andrew Saxon
6086 3 Ian Thompson
6086 4 Ian Thompson
6086 5 Phil Dargan

Brlliant minds any solution for this..
i know can i loop through the records and do it
and check for a new manager
but i want a better solution ..
give me your ideads folks..

Regards,
Navin Mahindroo


Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
by: dunleav1 | last post by:
I have a process that does inserts that runs 50% slower that Oracle and Mssql. Queries normally take 50% slower than normal. DB2, Oracle, Mssql all are configured on same os, same disk array...
7
by: ammmmmu | last post by:
Hi all, I am using VB 5.0 and msaccess as a database, I am reading the data from logfiles and inserting it in db, its not throwing any error, but after excecution I not find any records in table...
6
by: Abandoned | last post by:
Hi.. I use the threading module for the fast operation. But i have some problems.. This is my code sample: ================= conn =...
5
by: =?Utf-8?B?bXBhaW5l?= | last post by:
Hello, I am completely lost as to why I can't update a DropDownList inside a DetailsView after I perform an insert into an object datasource. I tried to simply it down to the core demostration:...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.