473,386 Members | 1,790 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,386 software developers and data experts.

SQL Query - Newbie help with summaries

Hello. I am trying to produce a SQL report query that determines the type (model) of system a user has and based off of that information, CASE selects to determine the amount of and type of memory needed to upgrade to 1GB. What I need to do is find a way to tally the information at the end of the report to produce a summary. I was thinking about trying a GROUP BY and SUM on that, but haven't been able to get it to work properly. Any thoughts on how I can approach this?

Thanks in advance for any help,
UCG

------------------------------------------------------------------------------------------
select distinct
v_GS_Computer_system.Name0 AS "PC Name"
, v_GS_Computer_system.UserName0 AS "User last logged on"
, v_GS_Operating_System.caption0 AS "OS"
, v_gs_Operating_system.csdversion0 AS "SP Level"
, v_GS_Computer_system.manufacturer0 AS "Make"
, v_GS_Computer_system.model0 AS "Model"
, v_GS_x86_PC_memory.totalphysicalmemory0 AS "RAM Installed"

, case v_GS_Computer_system.model0
when 'Virtual Machine' then 'Virtual'
when 'VMware Virtual Platform' then 'Virtual'
when 'Evo D310v' then '1'
when 'Evo D510 CMT' then '1'
when 'Evo D510 SFF' then '1'
when 'Evo W4000' then 'Unknown - Varies'
when 'Workstation W6000' then 'Unknown - Varies'
when 'HP dx5150 SFF(PZ585UA)' then '1'
when 'HP d220 MT (DS941A)' then 'Unknown - Varies'
else 'Unknown'
end as 'RAM quantity to achive 1GB'

, case v_GS_Computer_system.model0
when 'Virtual Machine' then 'Virtual'
when 'VMware Virtual Platform' then 'Virtual'
when 'Evo D310v' then '1GB PC2700'
when 'Evo D510 CMT' then '1GB PC2700'
when 'Evo D510 SFF' then '1GB PC2700'
when 'Evo W4000' then 'Need to examine system'
when 'Workstation W6000' then 'Unknown - believe 2 GB'
when 'HP dx5150 SFF(PZ585UA)' then '1GB PC3200'
when 'HP d220 MT (DS941A)' then 'Need to examine system'
else 'Unknown'
end as 'Ram Type'

, v_gs_processor.maxclockspeed0 AS "CPU Speed"

, cast(v_gs_video_controller.CurrentHorizontalResolu tion0 as Varchar) + ' x
' + cast(v_gs_video_controller.CurrentVerticalResoluti on0 as varchar) AS
"Video Resolution"

from
v_gs_computer_system,
v_GS_x86_PC_memory,
v_GS_processor,
v_gs_video_controller,
v_GS_Operating_system

WHERE
v_gs_operating_system.resourceid = v_gs_computer_system.resourceid
and v_gs_computer_system.resourceid = v_gs_computer_system.resourceid
and v_GS_x86_PC_memory.resourceid = v_gs_computer_system.resourceid
and v_GS_processor.resourceid = v_gs_computer_system.resourceid
and v_GS_video_controller.resourceid = v_gs_computer_system.resourceid
and v_GS_Operating_system.caption0 NOT like '%2000 Server%'
and v_GS_Operating_system.caption0 NOT like '%Server 2003%'
and v_GS_video_controller.CurrentHorizontalResolution0 <> ""
and v_GS_x86_PC_memory.totalphysicalmemory0 < '1024768'

Order by
v_gs_computer_system.name0
------------------------------------------------------------------------------------------
Jan 31 '07 #1
2 2642
iburyak
1,017 Expert 512MB
I don't see what you want to summarize?
Show me end result that you are trying to get or show me your query that produces an error so I could help you if possible.
Jan 31 '07 #2
Thanks. There are a number of systems in the database (it is an SMS database) and the query itself is much larger, but I trimmed it down to just a few example systems to post it here. I am trying to summarize the totals for the amount of RAM needed by RAM type, based on system model and I haven't been able to make it work.

When the query goes out, it determines the type of system (v_GS_Computer_system.model0). Based on the data, the query then will tell you the type of RAM that needs to be installed to achieve 1GB ('Ram Type'). There are a few thousand records and the query works fine itself to produce a detailed report showing each system and what is needed, but what I also need to figure out is how to total the ('RAM quantity to achive 1GB') field - which is not always going to be numeric - based on ('Ram Type'). I guess, in other words, I need the query to find all matching ('Ram Type') fields and provide a summary of the adjacent ('RAM quantity to achive 1GB'). I had thought of using a COUNT to simply count how many of each ('Ram Type') exists, but sometimes the ('RAM quantity to achive 1GB') may be more then 1. Also, I tried the GROUP BY and wanted to SUM the group, but could not get that to work properly either, as I cannot figure out the column name, The error that I receive with the GROUP BY is that the column name is incorrect when I try to use (v_GS_Computer_system.model0) or ['RAM quantity to achive 1GB'] or ['Ram Type'].

The problem for me has really come from the fact that both ('Ram Type') and ('RAM quantity to achive 1GB') come from the same (v_GS_Computer_system.model0) field. I hope that I explained that properly?

It has been a while since I have done SQL queries and I am definately rusty on this subject.

Thanks in advance for any assistance,
UCG
Feb 1 '07 #3

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

Similar topics

5
by: blueghost73 | last post by:
Ok, I know this is a stupid newbie question, but I'm a stupid newbie, so it fits. I've got a query that writes a basic report, and I need to be able to give it to a user who doesn't even know...
3
by: Lapchien | last post by:
A user has a make table query, basically it does some summing and creates a 'summary' table. I'd like to get rid of it (it's the last one in the access back-end) and use pure sql. Is the same...
1
by: Yorgos | last post by:
Hi! I have three tables of hockeystats players seasons goaliestats ___________ _____________ ______________ |*id |- |*id |- |*id |...
1
by: richard | last post by:
I have a table of raw sales data which I want to query, so the output can be imported into Excel and charted. The raw data looks like this, with one record for each sale: table 'data' ...
8
by: Thomas A. Anderson | last post by:
I have ran into a rut! I have google'd, Yahoo'd, but could not find the proper syntax. I have spent over two day trying to figure this out, and decided that I will have to ask for help from the...
1
by: jcwishart | last post by:
My table looks like this: Sales(a)||Date(a)||Sales(b)||Date(b)||Sales(c)||Date(c) 1) 50 05/06 75 06/15 100 08/15 So I want to show all sales with the criteria...
5
by: marcsirois | last post by:
I have an SQL Query that looks like this. I simplified it for the purpose of this example, but it's still a runnable query SELECT TOP 1 FundedPositions.PositionNumber AS , (select top 1...
8
by: AnndieMac | last post by:
I have an Access 2002 database of inventory count results, and I have been asked to create summaries of the items with the most losses at a store, region and national level. Individually, I have been...
11
by: Stan | last post by:
I am using MS Office Access 2003 (11.5614). I have been running the following query with good results. The query lets me enter the month period and returns the SUM of the age fields. SELECT ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...

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.