August 5, 2009 at 6:51 am
Hi all,
I have a table with columns softwares,version,licenseno,status(installed/uninstalled). I would like to display the result as
softwaresversiontotalinstalleduninstalled
MSOffice XP 150 100 50
Can any one please reply how can i achieve this....
thanks
kumar.
August 5, 2009 at 8:42 am
We'd like to see you try. This isn't consulting where we do the work, but rather where we help.
If you need to summarize data, you can use COUNT() or SUM(), depending on what you are trying to do. Read about them in books online.
Basically you'll run a select with the software column and the sum or count on the other columns, and add a GROUP BY in your query for the software.
August 5, 2009 at 11:49 pm
Thanks for the reply
I tried the bellow queries
1) To get total product count
"select product,versionnumber,count(*) from net_productinfo group by product,versionnumber order by product"
2) To get availabile products
"select product,versionnumber,availability,count(*) from net_productinfo where availability like 'A' group by product,versionnumber,availability order by product"
3) To get Unavailable products
"select product,versionnumber,availability,count(*) from net_productinfo where availability like 'N' group by product,versionnumber,availability order by product"
My intension is to get the result of all three queries in a single Row like " product,versionnumber,total,available,unavailable "
Please provide guidelines for me
Thanks,
kumar.
August 6, 2009 at 12:04 am
It's called a "Cross Tab"...
SELECT Product,
VersionNumber,
COUNT(*) AS Total,
SUM(CASE WHEN Availability = 'A' THEN 1 ELSE 0 END) AS Available,
SUM(CASE WHEN Availability = 'N' THEN 1 ELSE 0 END) AS UnAvailable
FROM dbo.Net_ProductInfo
GROUP BY Product, VersionNumber
ORDER BY Product, VersionNumber
--Jeff Moden
Change is inevitable... Change for the better is not.
August 6, 2009 at 10:02 pm
Excellent.........
It is working
Thanks,
have a good day,
kumar
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply