Viewing 15 posts - 1,141 through 1,155 (of 1,491 total)
In SQL2005, the best I can come up with for the sequence idea is a #temp table and two recursions. (As below)
If anyone can do any better I would be...
August 22, 2007 at 7:23 am
You may want something like the following. If not you will need to post test data and expected results in order for the problem to be understood.
DECLARE @t TABLE
(
[Proc] varchar(10)...
August 21, 2007 at 10:58 am
ORDER BY
CASE @SortBy
WHEN 'S'
THEN
CASE
WHEN column1 IS NULL AND column2 IS NULL
THEN ''
WHEN column1 IS NULL
THEN SPACE(255) + CAST(column2 AS varchar(255))-- 255 or length column1
WHEN column2 IS NULL
THEN CAST(column1 AS varchar(255))
ELSE...
August 20, 2007 at 6:56 am
ORDER BY
CASE @SortBy
WHEN 'S'
THEN ISNULL(CAST(column1 AS VARCHAR(255)) + ',', '') + column2
ELSE ISNULL(CAST(column3 AS VARCHAR(255)) + ',', '') + column2
END
August 20, 2007 at 6:15 am
SELECT *
FROM InvoiceDetails D
JOIN InvoiceSubDetails S
ON D.[ID] = S.InvoiceDetailID
JOIN (
SELECT S1.InvoiceDetailID
,COUNT(*) AS SubCount
FROM InvoiceSubDetails S1
GROUP BY S1.InvoiceDetailID
) V
ON D.[ID] = V.InvoiceDetailID
ORDER BY V.SubCount
August 20, 2007 at 6:08 am
SELECT
CASE N.Number
WHEN 1 THEN 'ParAmt'
WHEN 2 THEN 'DenomQty'
WHEN 3 THEN 'CInsNbr'
WHEN 4 THEN 'HNbr'
END AS Col
,CASE N.Number
WHEN 1 THEN ParAmt -- cast to float if not already float
WHEN 2 THEN...
August 17, 2007 at 8:01 am
SELECT
CASE N.Number
WHEN 1 THEN 'ParAmt'
WHEN 2 THEN 'DenomQty'
WHEN 3 THEN 'CInsNbr'
WHEN 4 THEN 'HNbr'
END AS Col
,CASE N.Number
WHEN 1 THEN ParAmt -- cast to float if not already float
WHEN 2 THEN...
August 17, 2007 at 7:51 am
It strikes me that we may have been seduced by our inner low level programmer. Maybe all that is required is a 256 row lookup table which...
August 17, 2007 at 3:17 am
I think the following is standard ANSI so it may work:
UPDATE FFIITMAP
SET FFIHGTH = (
SELECT MAX(C.CFFIHGTH)
FROM cubiscan C
WHERE C.CFFIITMN = FFIITMAP.FFIITMN
GROUP BY C.CFFIITMN
)
WHERE EXISTS (
SELECT *
FROM cubiscan C1
WHERE C1.CFFIITMN = FFIITMAP.FFIITMN
)
August 16, 2007 at 11:06 am
He seems to want to reverse the bits in a tinyint and then show the number in Hex.
Maybe:
-- From http://www.cs.utk.edu/~vose/c-stuff/bithacks.html#ReverseByteWith64BitsDiv
DECLARE @big1 bigint
,@big2 bigint
SELECT @big1 = 8623620610
,@big2 = 1136090292240
-- result may...
August 16, 2007 at 8:49 am
It is the ROW_NUMBER() example in the above link which is likely to be the most efficient. eg
SELECT D.BossID, D.KillID
FROM (
SELECT ROW_NUMBER() OVER (PARTITION BY BossID ORDER BY KillID) AS...
August 14, 2007 at 7:56 am
I do not know MySQL but you could try standard ANSI syntax:
UPDATE tblSchedule
SET HomeScore = 14
,AwayScore = 17
WHERE HomeTeamID = (
SELECT T1.[id]
FROM tblTeams T1
WHERE T1.FirstName = 'New England'
AND T1.LastName =...
August 14, 2007 at 3:31 am
As has already been mentioned, IN is generally not a good idea.
The most efficient queries usually use either JOINs or EXISTs depending on what you want.
-- eg of IN
SELECT *
FROM...
August 8, 2007 at 5:57 am
1. It is not a good idea to prefix the slip_no with the order_id in the db. Do this in the front end or use a view.
2. In SQL2000 you...
August 3, 2007 at 4:41 am
Sorry about the CROSS JOIN. I do try to suppress my urge to put all the join conditions in the WHERE clause!
August 3, 2007 at 3:11 am
Viewing 15 posts - 1,141 through 1,155 (of 1,491 total)