Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
babloo
Starting Member
35 Posts |
Posted - 2013-03-13 : 10:21:45
|
I have already asked this type of question before but can not generate expected results with your suggestions using old answer, need your assistance again please.Previous thread:http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=183351This is my Query:select distinct case when XML LIKE '%STATUS="NEW"%' then 'NEW Docs' when XML LIKE '%STATUS="OLD"%' then 'OLD Docs' end as GroupName,SUM(Size) as Size1,count(*) as Totalfrom contentsWhere (XML LIKE ('%STATUS="NEW"%') OR (XML LIKE '%STATUS="OLD"%' ))Group by xml,case when XML LIKE '%STATUS="NEW"%' then 'NEW Docs' when XML LIKE '%STATUS="OLD"%' then 'OLD Docs'endorder by SUM(Size), TotalResults right now: NEW Docs 8402 1NEW Docs 9715 1NEW Docs 11112 1OLD Docs 92948 1Expected results:NEW Docs 58458 3OLD Docs 92948 1Thank you.Babloo |
|
babloo
Starting Member
35 Posts |
Posted - 2013-03-13 : 10:24:25
|
Sorry had to edit the URL, it was wrong. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-13 : 10:27:24
|
[code]select casewhen XML LIKE '%STATUS="NEW"%' then 'NEW Docs'when XML LIKE '%STATUS="OLD"%' then 'OLD Docs'end as GroupName,SUM(Size) as Size1,count(*) as Totalfrom contentsWhere (XML LIKE ('%STATUS="NEW"%') OR (XML LIKE '%STATUS="OLD"%' ))Group by casewhen XML LIKE '%STATUS="NEW"%' then 'NEW Docs'when XML LIKE '%STATUS="OLD"%' then 'OLD Docs'endorder by Size1, Total[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
babloo
Starting Member
35 Posts |
Posted - 2013-03-13 : 10:37:33
|
Thanks again Visakh appreciate your help. |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-13 : 10:39:09
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|