473,397 Members | 2,084 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.

Help with DECODE function and crosstab query

I'm a newbie at Oracle..Be gentle!

I have a table that stores information (WMI data) about computers on
our network. The table looks like:

ComputerID
ItemID
Class
Property
Value

Each row in the table contains WMI data for a specific WMI class and
property and for a specific computer. A sample of data that shows a
software package installed on a computer might look like:

ComputerID ItemID Class Property Value
---------------------------------------------------------------------------
1 1 Win32_Product Name Visio
1 1 Win32_Product Vendor Microsoft
1 1 Win32_Product InstallDate 100103
1 2 Win32_Product Name Symnatec
1 2 Win32_Product Vendor Norton
Antivirus
1 2 Win32_Product InstallDate 092503

In this case, ItemID is used to "group" the data together, since a
single software package will contain multiple rows of data. (Three in
this case.)

What I need to be able to do is write a query that will do something
like show the software installed for a particular computer, and
display something like:

Software Vendor Installed
---------------------------------------------------------------------
Visio Microsoft 100103
Norton Antivirus Symnatec 092503

I've read up on the DECODE function but I've not been able to get my
queries to work and I'm really not sure I'm even going in the right
direction? Can anyone shed some light on what this query would look
like?

Remember, showing installed software is just an example of what one
query would look. I understand that if this is all I wanted out of
WMI, then I would just build a normalized table. If we were to build a
database that resembled everything WMI could hold, it would be a huge.
This is a small application, but we want the flexibility of allowing
the users to request any piece of WMI data without having to change
the database schema. Potentially, it might be storing CPU information,
hotfix info, TCP/IP stack info, etc. That's why the de-normalized
table structure was chosen. Is there a better way to accomplish what
we need?

Thanks in advance for any pointers or tips!
Jul 19 '05 #1
2 14551
/* create table gtbl(ComputerID number,ItemID number,Property
varchar2(20),value varchar2(20));

insert into gtbl values(1,1,'Name','Visio');
insert into gtbl values(1,1,'Vendor','Microsoft');
insert into gtbl values(1,1,'InstallDate','100103');
insert into gtbl values(1,2,'Name','Symnatec');
insert into gtbl values(1,2,'Vendor','Norton');
insert into gtbl values(1,2,'InstallDate','092503');

*/

SQL Query:

1 select
2 max( decode( property, 'Name', value, null ) ) Software,
3 max( decode( property, 'Vendor', value, null ) ) Vendor,
4 max( decode( property, 'InstallDate', value, null ) ) Installed
5 from gtbl
6 where computerid = &cid
7* group by itemid
SQL> /
Enter value for cid: 1
old 6: where computerid = &cid
new 6: where computerid = 1

SOFTWARE VENDOR INSTALLED
-------------------- -------------------- --------------------
Visio Microsoft 100103
Symnatec Norton 092503

Regards,
Siva Valiveru
Jul 19 '05 #2
Jan
didn`t test it, but you are looking for something like this:

SELECT computer_id,
item_id,
MAX(Name) Name,
MAX(Vendor) Vendor,
Max(Installed) Installed
FROM (
SELECT computer_id,
item_id,
DECODE(Property,'Name',Value) Name,
DECODE(Property,'Vendor',Value) Vendor,
DECODE(Property,'InstallDate',Value) Installed
FROM your_table)
GROUP BY computer_id, item_id

po********@hotmail.com (Mark Hoffman) wrote in message news:<a0**************************@posting.google. com>...
I'm a newbie at Oracle..Be gentle!

I have a table that stores information (WMI data) about computers on
our network. The table looks like:

ComputerID
ItemID
Class
Property
Value

Each row in the table contains WMI data for a specific WMI class and
property and for a specific computer. A sample of data that shows a
software package installed on a computer might look like:

ComputerID ItemID Class Property Value
---------------------------------------------------------------------------
1 1 Win32_Product Name Visio
1 1 Win32_Product Vendor Microsoft
1 1 Win32_Product InstallDate 100103
1 2 Win32_Product Name Symnatec
1 2 Win32_Product Vendor Norton
Antivirus
1 2 Win32_Product InstallDate 092503

In this case, ItemID is used to "group" the data together, since a
single software package will contain multiple rows of data. (Three in
this case.)

What I need to be able to do is write a query that will do something
like show the software installed for a particular computer, and
display something like:

Software Vendor Installed
---------------------------------------------------------------------
Visio Microsoft 100103
Norton Antivirus Symnatec 092503

I've read up on the DECODE function but I've not been able to get my
queries to work and I'm really not sure I'm even going in the right
direction? Can anyone shed some light on what this query would look
like?

Remember, showing installed software is just an example of what one
query would look. I understand that if this is all I wanted out of
WMI, then I would just build a normalized table. If we were to build a
database that resembled everything WMI could hold, it would be a huge.
This is a small application, but we want the flexibility of allowing
the users to request any piece of WMI data without having to change
the database schema. Potentially, it might be storing CPU information,
hotfix info, TCP/IP stack info, etc. That's why the de-normalized
table structure was chosen. Is there a better way to accomplish what
we need?

Thanks in advance for any pointers or tips!

Jul 19 '05 #3

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

Similar topics

15
by: Richard Hollenbeck | last post by:
I tried to ask this question before on the 14th of January but I never got a reply. I'm still struggling with the problem. I'll try to rephrase the question: I have a crosstab query with rows...
7
by: newguy | last post by:
I am trying to get the totals of a table by client by type of income. This query will get what I am looking for with each unique combination as a row: SELECT Sales.Client, BillCode.Type,...
2
by: Steven Taylor | last post by:
Hope someone can help. Table structure: Name : tbl_Runs Fields are: Run_ID Run_Date Run_Distance (km) Run_Duration (secs)
2
by: Nenad Markovic | last post by:
Hi everybody, When executing a Crosstab Query I see only rows (defined in a row heading) that have values (defined in value field) in at least one column (defined as column headings). How can...
8
by: Penny | last post by:
(Access 2003 Multiuser Split DB, Windows XP Pro) Hi All, I would really appreciate just some basic tips on how to make a Crosstab Form based on a Crosstab Query. The query always has the same...
13
by: salad | last post by:
Operating in A97. I didn't receive much of a response conserning Pivot tables in Access. Pivot tables are nice, but a CrossTab will work for me too. Using a Pivot table, one is actually...
2
by: Mark Hoffman | last post by:
I'm a newbie at Oracle..Be gentle! I have a table that stores information (WMI data) about computers on our network. The table looks like: ComputerID ItemID Class Property Value
2
by: Jim Devenish | last post by:
I wish to create a crosstab query as the record source for a report. It needs to count data between selected dates which are entered by the user in a popup window. The following Select query...
1
ollyb303
by: ollyb303 | last post by:
Hello, I have been using the following expression in Access as part of a statement to query an Oracle database: (Sum(CASE WHEN STATS_DAILY_SA.LOGIN_TIME > (STATS_DAILY_SA.SCHEDULED_TIME -...
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
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
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.