Viewing 15 posts - 31 through 45 (of 49 total)
Simon,
I'm not sure I understood your specs correctly, but a CASE statement is what you need to use.
SELECT
OwnContact
,
RevenueTotal
,
CASE
February 27, 2006 at 5:00 pm
Steve,
You could use a RS matrix instead of a table. You'd need to modify your query to a series of unions that include the column names as well as their...
February 27, 2006 at 4:16 pm
PK
I exercised your example, and although I had to force the JOIN version to use the index with a WITH ( INDEX ... ) it clearly is more efficient than my...
February 10, 2006 at 2:12 pm
Nice to learn that I'm not the only one who's made Classic mistakes...
PW - I'm curious why you included the test in the JOIN instead of modifying the WHERE clause...
February 10, 2006 at 1:23 pm
Chris,
Jeff is right on. The LEFT JOIN is needed to include Clients w/o Tickets. COUNTing ( t.TicketID ) as opposed to (*) is the other trick.
February 10, 2006 at 1:07 pm
Unless your using RS 2005 your limited to a single entry per text box. You could parse an entry ( 1000,2000 etc) into a @table variable prior to using it as...
February 7, 2006 at 9:07 am
Herb,
I ran into the same limitation that you are. UDF's that return a table are only executed once.
From Books On Line
You can invoke a user-defined function that returns a...
January 31, 2006 at 6:41 pm
I think you have at least two ways to go.
a) Create a view that UNIONs the contents of your various mailing lists, appending the table name as a column. Downside...
January 20, 2006 at 3:20 pm
You may want to try using a matrix instead of a table. I'm new to matrixs, but they will pivot the data based on any column(s)? in the data set.
Mike
January 12, 2006 at 3:11 pm
I think this is what your looking for.
SELECT
o1.Machine,
o1.OrderNum,
( SELECT TOP 1
o2.OrderNum
FROM
[Order] o2
WHERE
O2.Machine = o1.Machine AND o2.ProductionDate < o1.ProductionDate
ORDER BY
o2.ProductionDate DESC
...
January 10, 2006 at 2:50 pm
DATETIME is a better choice than SMALLDATETIME, but I would hesitate to use either as a primary key. Consider the effect of needing to adjust your timeclock backwards, or having data introduced...
December 2, 2005 at 10:15 am
Robb,
I posed a similar question a short while back. The answer I got makes sense, even though it wasn't what I was hoping for. Consider the following:
CREATE PROCEDURE test
@p1...
November 15, 2005 at 1:14 pm
TransData td
LEFT OUTER JOIN Code c ON td.GLAcct = c.Code
LEFT OUTER JOIN @ExcludedGLAccounts e ON e.GLAcct= td.GLAcct
WHERE e.GLAcct IS NULL
I'd benchmark one method against the other...
November 1, 2005 at 1:34 pm
select
u.username,
(select top 1 gm.groupname
from tbl_groupmemberships gm
where u.id=gm.userid
order by gm.id ) as 'groupname'
from
tbl_users u
where exists
(select gm.groupname
from tbl_groupmemberships gm
where u.id=gm.userid )
November 1, 2005 at 9:18 am
Viewing 15 posts - 31 through 45 (of 49 total)