473,625 Members | 3,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 14598
/* create table gtbl(ComputerID number,ItemID number,Property
varchar2(20),va lue varchar2(20));

insert into gtbl values(1,1,'Nam e','Visio');
insert into gtbl values(1,1,'Ven dor','Microsoft ');
insert into gtbl values(1,1,'Ins tallDate','1001 03');
insert into gtbl values(1,2,'Nam e','Symnatec');
insert into gtbl values(1,2,'Ven dor','Norton');
insert into gtbl values(1,2,'Ins tallDate','0925 03');

*/

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********@hotm ail.com (Mark Hoffman) wrote in message news:<a0******* *************** ****@posting.go ogle.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
4392
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 of students and columns of activities and the data are the students' scores in each activity. No problem, almost. The problem is that there are five classes at the moment and will be more classes (or courses) in future semesters. I don't want...
7
1902
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, Sum(Sales.Amount) FROM Invoice_Details INNER JOIN BillCode ON Sales.BillCode = BillCode.id GROUP BY Client, Type;
2
1579
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
2931
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 I make a Crosstab Query that shows all rows, regardless they have values in column headings. For instance, the result that I get now is like this
8
6071
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 number of records(generated from a table of predefined 'timeslots'). The number of columns(one for each Consultant) varies depending on how many of the Consultants have a yes/no field('Participates') set to yes. Therefore the Crosstab query...
13
17133
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 launching Excel for data viewing. I'd prefer the user stay in Access. Creating dynamic crosstab queries is pretty simple. The problem is that the column count may shrink or grow depending on the filter.
2
238
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
3396
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 works: SELECT Tasks.EnquirySourceID, Tasks.BusinessUnitID, Count(Tasks.TaskID) AS CountOfTaskID FROM Tasks WHERE (((Tasks.TaskDate)>=!!)) GROUP BY Tasks.EnquirySourceID, Tasks.BusinessUnitID;
1
5480
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 - DECODE(STATS_DAILY_SA.EXCEPTION_TIME, Null, 0, STATS_DAILY_SA.EXCEPTION_TIME)) THEN 0 ELSE ((STATS_DAILY_SA.SCHEDULED_TIME - DECODE(STATS_DAILY_SA.EXCEPTION_TIME, Null, 0, STATS_DAILY_SA.EXCEPTION_TIME)) - STATS_DAILY_SA.LOGIN_TIME)...
0
8189
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
8694
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
8635
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8356
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
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...
1
6118
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
5570
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();...
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1500
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.