none
Trying to Sort by Count RRS feed

  • Question

  • So I seem to be hitting a brick wall here.  I'm making a simple report for SCCM in ReportBuilder and I can't get it to sort the results by count. 

    Here is my Query:

    SELECT    
    Model0,
    Manufacturer0,
    COUNT (Model0) Cnt
    FROM v_GS_COMPUTER_SYSTEM
    GROUP BY Model0,Manufacturer0
    ORDER BY Cnt

    My goal is a report with model and manufacturer sorted by the count.

    Thursday, March 14, 2019 2:07 PM

All replies

  • Hi,

    You can get it sorted in the report instead of doing it in the query.


    Ousama EL HOR

    [If a post helps to resolve your issue, please click the "Mark as Answer"  of that post or click Answered "Vote as helpful"  button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


     [User Page]     [MSDN Page]     [Blog]     [Linkedin]

    Thursday, March 14, 2019 2:13 PM
  • Cannot reproduce  it

    create table #t (id int,m int, d int)

    insert into #t values (10,4,5)
    insert into #t values (10,4,1)
    insert into #t values (10,2,2)

    insert into #t values (14,6,5)
    insert into #t values (14,6,1)

    select id,m, count(d) cnt 
    from #t group by id,m
    order by cnt desc


    Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/

    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting: Large scale of database and data cleansing
    Remote DBA Services: Improves MS SQL Database Performance
    SQL Server Integration Services: Business Intelligence

    Thursday, March 14, 2019 2:15 PM
  • How would I sort it in the report?
    Thursday, March 14, 2019 2:16 PM
  • In the Tablix properties -> Sorting Tab and then add the column that you want it to be sorted.

     

    Ousama EL HOR

    [If a post helps to resolve your issue, please click the "Mark as Answer"  of that post or click Answered "Vote as helpful"  button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


     [User Page]     [MSDN Page]     [Blog]     [Linkedin]

    Thursday, March 14, 2019 2:23 PM
  • I added that in and it still sorts it by the Model.  AM I doing this incorrectly?

    Thursday, March 14, 2019 2:29 PM
  • Found it I think!  I went into the section at the bottom for Row Groups and changed the sorting there to sort by Count.

    Thursday, March 14, 2019 2:55 PM
  • Hi Jannin,

    Does it works as you want ? If you find it solved your problem, you could mark above post as answer. This could help people with similar issues to find their answer.

    regards,

    Lukas


    MSDN Community Support Please remember to click Mark as Answer; the responses that resolved your issue, and to click Unmark as Answer if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, March 15, 2019 5:48 AM