473,404 Members | 2,195 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,404 software developers and data experts.

Table with various subfleets

I have a table with 4 columns: Fleetname, FleetId, ParentFleetId, VehicleId.
My Fleet has 16 Sub Fleets where Cipro is one of them. I listed the Sub Fleets of Cipro as well (Cipro sundry, Finance and Procurement).

Fleet Name: My Fleet
Fleet ID: 9814

Sub Fleet1 (below My Fleet)
Fleet Name: Cipro
Fleet ID: 42263
ParentFleetId: 9814

Sub Fleet2 (below Cipro)
Fleet Name: Cipro sundry
Fleet ID: 42264

Sub Fleet3 (below Cipro sundry)
Fleet Name: Finance and Procurement
Fleet ID: 43912

How can I get all of the VehicleId's of My Fleet, each of the 16 Sub Fleets of My Fleet and all their VehicleId's, plus all their Sub Fleets and their VehicleId's into a new table with the following columns and format.

Fleet1, FleetID1, Fleet2, FleetID2, Fleet3, FleetID3, Fleet4, FleetID4, VehicleId
-----------------------------------------------------------------------------------------------------------------
My Fleet, 9814, Null, Null, Null, Null, Null, Null, 120498
Null, Null, Cipro, 42263, Null, Null, Null, Null, 120409
Null, Null, Null, Null, Cipro sundry, 42264, Null, Null, 120097
Null, Null, Null, Null, Null, Null, Finance and Procurement, 43912, 120333


I guess I can use a cursor for this, but I want something that can automate the insert in table (dont want to query by FleetId, etc).
Can anyone help ?
Oct 1 '09 #1
1 1029
ck9663
2,878 Expert 2GB
Try to gather all the records first then PIVOT/UNPIVOT your result set.

Happy Coding!!!

--- CK
Oct 7 '09 #2

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

Similar topics

1
by: Philo | last post by:
How do I select all <div> tags except those which contain a <table> tag somewhere within them? Example XML: <********************** sample input ***********************> <txtSectionBody>...
10
by: John | last post by:
I have a table with two rows. On the first row is a text box and in the second row is an image. I have set the table cellpadding to 0 and cellspacing to 0. The table is leaving extra spaces in the...
61
by: Toby Austin | last post by:
I'm trying to replace <table>s with <div>s as much as possible. However, I can't figure out how to do the following… <table> <tr> <td valign="top" width="100%">some data that will...
47
by: Neal | last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A quite good article.
5
by: aboycalled3 | last post by:
I'm interested in using the fascinating CSS available at http://www.moronicbajebus.com/playground/cssplay/reformat-table/ which allows one to present tabular data in a way that's more appealing...
3
by: harry | last post by:
I want to be able to change the text alignment within a table cell between "right" & "center" depending on how many rows are in the table. Is this possible in Javascript? - can't see how to do...
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 ...
2
by: clickon | last post by:
I am confused about the way in which asp:table objects work. When a control is within an asp table it generally appears to be in the scope of the tables parent control. E.g. if i have a page that...
9
by: PeteCresswell | last post by:
I've got something called "Reference Rates". The idea is that on a given day, we have various rates of return for various entities. e.g. Libor 3-month return, Libor 6-month return, US Treasury...
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
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
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...
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
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
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.