|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: 2 days ago @ 8:31 AM
Points: 3,129,
Visits: 4,312
|
|
Comments posted to this topic are about the item Count Distinct
____________________________________________ Space, the final frontier? not any more... All limits henceforth are self-imposed. “libera tute vulgaris ex”
|
|
|
|
|
SSCrazy Eights
        
Group: General Forum Members
Last Login: Yesterday @ 2:11 AM
Points: 9,378,
Visits: 6,473
|
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Yesterday @ 12:56 AM
Points: 1,972,
Visits: 1,822
|
|
| I get it right because of excluding the wrong choices.
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Monday, September 17, 2012 7:30 AM
Points: 1,038,
Visits: 679
|
|
| Nice Question,needs little bit time to go through the Query
|
|
|
|
|
Say Hey Kid
      
Group: General Forum Members
Last Login: Wednesday, September 21, 2011 4:03 AM
Points: 713,
Visits: 100
|
|
I was sure that "we can Aggregate by columns not included in the SELECT", but I wasn't aware of that use of DISTINCT in Aggregate function, so I had to experiment the same on my own database.
Great Question, really learned something new.
Regards,
-------------------------------------------------------------------------------- Mayank Parmar Software Engineer Clarion Technologies SEI CMMI Level 3 Company 8th Floor, 803, GNFC info Tower, SG Highway, Ahmedabad - 380 054, Gujarat, India. www.clariontechnologies.co.in Email: mayank.parmar@clariontechnologies.co.in MSN : mayank.parmar@clariontechnologies.co.in Mobile: +91 9727748789 --------------------------------------------------------------------------------
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Thursday, January 24, 2013 9:59 PM
Points: 1,354,
Visits: 1,299
|
|
Carlo Romagnano (1/21/2011) I get it right because of excluding the wrong choices. Exactly how I did it too.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Monday, December 17, 2012 2:20 PM
Points: 153,
Visits: 70
|
|
I was not aware about, that you can use Columns in a having Clause without having the Column in the SELCET.
However, a nice one.
Greetings R2d2
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Wednesday, May 22, 2013 1:10 PM
Points: 2,673,
Visits: 2,418
|
|
| I have never thought of using count and count distinct in a having clause the way you do. Brilliant. Thanks.
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Yesterday @ 11:01 AM
Points: 335,
Visits: 609
|
|
| I tested this. It doesn't seem to work correctly everytime. But I had never thought of using distinct in a having clause, so nice.
|
|
|
|
|
UDP Broadcaster
      
Group: General Forum Members
Last Login: Wednesday, April 17, 2013 10:57 PM
Points: 1,491,
Visits: 3,008
|
|
rollec2k5 (1/21/2011) I was not aware about, that you can use Columns in a having Clause without having the Column in the SELCET.
Not exactly.... The HAVING clause can use aggregates like COUNT(), MAX(), SUM() and so on which themselves refer to other columns, but it may not directly refer to a column not in the GROUP BY clause which in turn can only use columns or non-aggregate expressions in the SELECT.
|
|
|
|