Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 123»»»

What's the count? Expand / Collapse
Author
Message
Posted Wednesday, March 10, 2010 9:18 PM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, October 31, 2011 1:10 PM
Points: 480, Visits: 1,163
Comments posted to this topic are about the item What's the count?

--
Post #880671
Posted Wednesday, March 10, 2010 11:02 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 9:11 PM
Points: 17,601, Visits: 15,465
Thanks for the question. Nice job.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #880708
Posted Wednesday, March 10, 2010 11:19 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 8:47 AM
Points: 2,296, Visits: 1,427
Nice Question ....Today i learned this from Central...Good Question
Post #880717
Posted Thursday, March 11, 2010 12:13 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, December 11, 2013 7:12 AM
Points: 366, Visits: 455
Good question..never thought of using count(*) for 2 tables in one T-SQL...thanks for question
Post #880751
Posted Thursday, March 11, 2010 12:50 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 15, 2011 10:49 PM
Points: 5, Visits: 10
count is basically. Counting the each record of that table.
For Example. Table A has 3 rows then count = 3. if table B has 4 Rows then count=4.
If combine both tables then 3 * 4 = 12 rows and count = 12
Post #880768
Posted Thursday, March 11, 2010 1:05 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 12:53 AM
Points: 2,529, Visits: 2,402
if one table has one o more rows and the other is void, the result is 0.
NumberOfRows * 0 = 0
Post #880775
Posted Thursday, March 11, 2010 2:03 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, January 21, 2014 7:57 AM
Points: 2,173, Visits: 344
In Point of Interview Very Intelligence Question ......Nice...hmmmmm My Answer is Correct............!
Post #880809
Posted Thursday, March 11, 2010 2:31 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Thursday, September 18, 2014 2:51 AM
Points: 1,743, Visits: 485
That's is a good question, illustrating the need for careful joins!

For those that don't know, this kind of result is called a "cartesian product", and if you allow it to happen in a real-world application with even a few hundred rows in either table, you are in for something of an explosion of complaints from your users, to say the least.

Ken.
Post #880821
Posted Thursday, March 11, 2010 3:43 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, September 19, 2014 2:42 AM
Points: 1,167, Visits: 2,652
Very good question.

However I think that the explanation is a bit lacking, and could explain in more detail what is happening here and what a 'cross join'/'cartesian product' is.

Here are some links that may help:

Cross Join
Cartesian Product


--
Nigel
Useful Links:
How to post data/code on a forum to get the best help
The "Numbers" or "Tally" Table - Jeff Moden

Post #880860
Posted Thursday, March 11, 2010 8:08 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 7:35 AM
Points: 2,817, Visits: 2,563
This one definitely made me think a minute or two.
Post #881038
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse