Viewing 15 posts - 1,246 through 1,260 (of 1,418 total)
It has been some time since I have converted outer joins from old style to new style format, however there are generally two points to bear in mind:
1. With the...
February 5, 2007 at 5:19 am
You need to SUM the CatchNumber. Something like the following should work:
SELECT A.ShipName, A.FishingDate, A.FishingLocation, D.Jack, D.Rose
FROM TABLE1 A
JOIN (
SELECT B.ShipName
,B.FishingDate
,SUM(CASE B.FishSpecies WHEN 'Jack' THEN CatchNumber END) AS Jack
,SUM(CASE B.FishSpecies...
February 1, 2007 at 2:48 am
BOL gives good documentation on locking. In brief it appears you were confused between the lock granularity, ROWLOCK, PAGLOCK, TABLOCK etc and the lock type, shared, UPDLOCK, XLOCK etc.
In your...
January 31, 2007 at 7:05 am
For code like this to work you need to use UPDLOCK, or XLOCK, and have an index...
January 30, 2007 at 9:41 am
Something along the lines of the following should work:
SELECT Y.*
FROM YourTable Y
JOIN (
SELECT Y1.[ID], MAX(Y1.PAT_TO_DATE) AS PAT_TO_DATE
FROM YourTable Y1
GROUP BY Y1.[ID]) D
ON Y.[ID] = D.[ID] AND Y.PAT_TO_DATE = D.PAT_TO_DATE
January 26, 2007 at 8:16 am
The question is not very clear.
If there are not too many rows (less that 10,000?) something like the following triangular join may
be what you want. With a lot of rows...
January 25, 2007 at 10:06 am
A trigger should work although it would probably be more efficient to code the logic when you INSERT or UPDATE. If you want to use a trigger, something like the...
January 23, 2007 at 10:03 am
This may work. It uses derived tables, only one column in the GROUP BY
and an EXISTS subquery to avoid the overhead of a DISTINCT.
SELECT ISNULL(D.PCCount, 0) AS PCCount
,P.Postcode, P.Town,...
January 23, 2007 at 8:08 am
Assumming UkPostcodes.Postcode contains the postcode district and Customers_Trade.Postcode
contains the full postcode, how about:
SELECT ISNULL(D.PCCount, 0) AS PCCount
,P.* -- or whatever columns you want
FROM dbo.UkPostcodes P
LEFT JOIN (
SELECT P1.Postcode
,COUNT(*) AS PCCount
FROM...
January 22, 2007 at 9:28 am
It is difficult to tell what you want and which columns are meant to match. In future please follow the instructions at http://www.aspfaq.com/etiquette.asp?id=5006
You may want to do something like...
December 13, 2006 at 8:35 am
'Won"t Fix' should be 'Won''t Fix'
ie Embed two single quotes, not one double quote.
eg SELECT 'Won''t Fix' AS STRING
STRING
---------
Won't Fix
(1 row(s) affected)
December 8, 2006 at 5:13 am
Unfortunately ROUND is a lot worse than FLOOR as six month ranges fail to show correctly.
dob DateFrom DateTo RoundAge CaseAge
-------- ------------ --------- -------- -------
19460624 19461224 19470623 1 0
19460624 19471224 19480623 ...
December 7, 2006 at 8:51 am
Use the REPLACE function. Something like:
SELECT *
FROM TableA A
JOIN TableB B ON A.PK = B.PK
WHERE REPLACE(REPLACE(A.ColWithCRLF, CHAR(13), ''), CHAR(10), '') <> B.ColWithoutCRLF
December 6, 2006 at 12:09 pm
Floor nearly works but it produces a rounding error every 4 years as below:
dob Birthday FloorAge CaseAge RoundingError
-------- -------- ----------- ----------- -------------
19460624 19460624 0 0 N
19460624 19470624 0 1 ...
December 6, 2006 at 8:13 am
Viewing 15 posts - 1,246 through 1,260 (of 1,418 total)