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»»»

Counts Puzzle Expand / Collapse
Author
Message
Posted Monday, August 25, 2008 11:43 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, November 19, 2013 2:10 AM
Points: 138, Visits: 236
Comments posted to this topic are about the item Counts Puzzle

Tariq
master your setup, master yourself.
http://mssqlsolutions.blogspot.com
Post #558602
Posted Tuesday, August 26, 2008 2:45 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, September 11, 2014 6:03 AM
Points: 312, Visits: 1,127
Shouldnt this be

SELECT C.CATID, COUNT(*)
FROM #DATA DINNER
JOIN #CATEGORY C ON (C.VAL1 = DINNER.VAL1) OR (C.VAL1 IS NULL)
GROUP BY C.CATID

(was ON C.VAL1 = D.VAL1)
Post #558681
Posted Tuesday, August 26, 2008 3:07 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, September 24, 2008 1:27 PM
Points: 350, Visits: 229
ian treasure (8/26/2008)
Shouldnt this be

SELECT C.CATID, COUNT(*)
FROM #DATA DINNER
JOIN #CATEGORY C ON (C.VAL1 = DINNER.VAL1) OR (C.VAL1 IS NULL)
GROUP BY C.CATID

(was ON C.VAL1 = D.VAL1)


Nope, its this:

SELECT C.CATID, COUNT(*)
FROM #DATA D INNER JOIN
#CATEGORY C ON (C.VAL1 = DVAL1) OR (C.VAL1 IS NULL)
GROUP BY C.CATID
Post #558687
Posted Tuesday, August 26, 2008 3:10 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, September 11, 2014 6:03 AM
Points: 312, Visits: 1,127
AAAAAA. Knew there was something I'd missed.
Post #558689
Posted Tuesday, August 26, 2008 4:53 AM
SSC-Addicted

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

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 3:37 AM
Points: 488, Visits: 405
ian treasure (8/26/2008)
Shouldnt this be

SELECT C.CATID, COUNT(*)
FROM #DATA DINNER
JOIN #CATEGORY C ON (C.VAL1 = DINNER.VAL1) OR (C.VAL1 IS NULL)
GROUP BY C.CATID

(was ON C.VAL1 = D.VAL1)

You must be like me ... always thinking of food
Post #558719
Posted Tuesday, August 26, 2008 5:10 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, November 19, 2013 2:10 AM
Points: 138, Visits: 236
hey,

here is the details,

1) inner join or join, its behavior is same, so there will be no effect if you replace inner join with join.

2) parenthesis will not change its behavior, because we have only two conditions in where clause to check, parenthesis will play role when you will have multiple combination of OR and AND operators.

so, i believe code is correct, :)


Tariq
master your setup, master yourself.
http://mssqlsolutions.blogspot.com
Post #558733
Posted Tuesday, August 26, 2008 5:39 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, September 23, 2014 2:10 PM
Points: 2,669, Visits: 781
There was also that new
grin nullgroup means no one invited
keyword NULLGROUP not far from the DINNER subquery.


Jamie
Post #558756
Posted Tuesday, August 26, 2008 7:57 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 12:37 PM
Points: 2,392, Visits: 17,941
mmmmm.... Dinner Join.... sounds like an invitation to a barbeque.

Reminds me of the QOD from 12/13/07 that used a MIDDLE JOIN. :)

Chad
Post #558885
Posted Tuesday, August 26, 2008 8:19 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, September 24, 2008 1:27 PM
Points: 350, Visits: 229
Round yours at 6 then :D
Post #558914
Posted Tuesday, August 26, 2008 10:39 AM


SSC-Addicted

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

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 8:22 AM
Points: 453, Visits: 102
skyline666 (8/26/2008)
ian treasure (8/26/2008)
Shouldnt this be

SELECT C.CATID, COUNT(*)
FROM #DATA DINNER
JOIN #CATEGORY C ON (C.VAL1 = DINNER.VAL1) OR (C.VAL1 IS NULL)
GROUP BY C.CATID

(was ON C.VAL1 = D.VAL1)


Nope, its this:

SELECT C.CATID, COUNT(*)
FROM #DATA D INNER JOIN
#CATEGORY C ON (C.VAL1 = DVAL1) OR (C.VAL1 IS NULL)
GROUP BY C.CATID


When you're copying the code to query window remember to add proper line brakes so you don't end up with "DINER Join" . Must've been hungry? Thanks for the laughs
Post #559042
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse