Viewing 15 posts - 1 through 15 (of 25 total)
I don't think so, because before that point we've already done our GROUP BY CustomerID, so really the 2 methods we're comparing are:
...
WHERE ProductCode IN (@A, @b-2)
--people that...
June 13, 2014 at 6:54 am
SwePeso (6/13/2014)
The COUNT(DISTINCT ...) approach will only return the groups that has exactly one A and one B.
Not sure about this, I thought the whole point of the DISTINCT is...
June 13, 2014 at 6:28 am
SwePeso (6/13/2014)
They are not equivalent and return different result.
Hmm, I'm going to be sceptical for now because I haven't found a case where any of the 3 solutions brought back...
June 13, 2014 at 5:56 am
Jonathan AC Roberts (6/12/2014)
Normally when an example is given using values A, B and C they should be taken as algebraic variables who's contents can change.
Agreed, it gives a solution...
June 13, 2014 at 4:52 am
Luis Cazares (6/12/2014)
But that won't work to find customers that bought A & C but not B. 😀
Haha! Yes Luis, good thing that A & C not B wasn't in...
June 12, 2014 at 9:13 am
For a miniscule (and mostly academic) improvement on PeSo's script,
I've got it so the index/table only gets scanned once (instead of 3 times)
by just using a BETWEEN instead of the...
June 12, 2014 at 8:47 am
SwePeso (6/6/2014)
SELECT CustomerID
FROM #Purchase
WHERE ProductCode IN ('A', 'B', 'C')
GROUP BY CustomerID
HAVING MIN(ProductCode) = 'A'
AND MAX(ProductCode) = 'C'
AND SUM(CASE WHEN ProductCode = 'B' THEN 1...
June 6, 2014 at 9:50 am
craig 81366 (6/6/2014)
The Wizard Of Oz (6/6/2014)
ben.norris (6/6/2014)
No you misunderstand, I don't mean the ordering of values within the table. Check the code for example to find customers who...
June 6, 2014 at 9:10 am
ben.norris (6/6/2014)
No you misunderstand, I don't mean the ordering of values within the table. Check the code for example to find customers who bought 'A' and 'C' but not...
June 6, 2014 at 8:45 am
ben.norris (6/6/2014)
The Wizard Of Oz (6/6/2014)
It would be strange if someone caught...
June 6, 2014 at 8:33 am
There's no dependance on ordering, so no cheating going on. It's a natural part of MIN() and MAX() functions.
It would be strange if someone caught SwePeso pulling a fast one,...
June 6, 2014 at 8:09 am
I tried getting the job names to pivot somehow in SQL 2000 (as we have a legacy server running it still...), but I gave up after a while too.
The closest...
June 14, 2013 at 3:37 am
When using sp_MSforEachDB or its brother sp_MSforEachTable, it's always a good idea to enclose any question marks in square brackets (if they map to object names) or quotes (if they...
May 30, 2013 at 3:31 am
Hi Lisa!
If you really want to see all the time-slots, not just the "interesting ones" (where 1 or more jobs are running),
then grab the now-fixed script from above and SET...
May 10, 2013 at 3:09 am
Here's the one I use day-to-day, it avoids cursors.
/* SQL 2005+ VERSION */
SELECT type_desc'Type',SUM(size)/128'TotalServerSizeMB'
FROM sys.master_files
GROUP BY type_desc
ORDER BY TotalServerSizeMB DESC
SELECT
database_id'dbID',
DB_NAME(database_id)'dbName',
file_id,
name'LogicalName',
type_desc'Type',
Physical_Name,
state_desc'Status',
differential_base_time'LastFullBackup',
...
April 24, 2013 at 6:59 am
Viewing 15 posts - 1 through 15 (of 25 total)