Viewing 15 posts - 301 through 315 (of 355 total)
SELECT *
FROM [MyTable]
WHERE ((CASE CalcLT
WHEN 1 THEN Col1
WHEN 2 THEN Col2
WHEN 3 THEN Col3
WHEN 4 THEN Col4
END) < 0)
February 13, 2009 at 6:14 am
Looks OK to me.
Presumably the number of consecutive days that an employee can take off is never going to exceed 100, so you won't run into problems with your synthetically...
February 13, 2009 at 3:34 am
Try specifying the length of the varchar local variables to match the length of the columns in your table schemas.
DECLARE
@newEmpID varchar,
@firstname varchar,
@lastname varchar
February 12, 2009 at 7:26 pm
The order of the columns in the SELECT statement used to declare your cursor
Select newEmpID, firstname, lastname FROM ausersOmega
should match up with the order of variables in your FETCH statement:
FETCH...
February 12, 2009 at 6:55 pm
Why are you using a cursor? it can be done with a single UPDATE statement.
UPDATE U SET employee_id = NU.newEmpID
FROM users U
JOIN ausersOmega NU ON (U.firstname = NU.firstname AND U.lastname...
February 12, 2009 at 6:34 pm
Does this do what you want?
The first SELECT includes a row for each single-day row in the source data regardless of the weekday.
The second SELECT in the UNION uses a...
February 12, 2009 at 6:07 pm
OK, will this work?
I've assumed that the ParentId column is NULL if the row is the original entry for that quote
SELECT R.QuoteId, R.ReferenceNumber, R.CustomerName, R.TotalAmount,
SaleType = CASE WHEN EXISTS (
SELECT...
February 12, 2009 at 4:40 pm
I'm writing a query for a receipt table. Whenever a return is processed, the current system inserts another record with the exact same information except with a negative amount and...
February 12, 2009 at 4:16 pm
You don't state what your total amout column name is, but assuming it is TotalAmount then does the following work?
SELECT R.QuoteId,
R.ReferenceNumber,
R.CustomerName,
MAX(R.TotalAmount),
CASE WHEN COUNT(*) > 1 THEN 'Reverted'...
February 12, 2009 at 3:56 pm
Here's another way of calculating the first and last days of the current month
SELECT FirstOfMonth = DATEADD(month, DATEDIFF(month, 0, GETDATE()), 0),
LastOfMonth = DATEADD(month, DATEDIFF(month, 0, GETDATE()) + 1, -1)
February 12, 2009 at 3:21 pm
In my solution I've used the following table schema, although using different column names will not make any difference.
CREATE TABLE dbo.Matrix (
RKey varchar(10) NOT NULL,
ColVal1 char(1) NULL,
ColVal2 char(1) NULL,
ColVal3 char(1)...
February 12, 2009 at 2:16 pm
If OP wants to select records where the date range in the table row overlaps the date range defined in the input parameters, then Vladan is right, and rtomkins' extra...
February 11, 2009 at 2:22 pm
What about national holidays? Should they be treated like Saturdays and Sundays? If so, you will need to use a calendar table.
A calendar table might be the best option...
February 11, 2009 at 1:54 pm
You haven't provided your full table schema, so in the following I've assumed a table named XmlTemplate as follows. I've assumed there is primary key field (id) on this table...
February 11, 2009 at 8:25 am
Does this query give you what you need?
It appears to replicate the output from your script.
A couple of points to note:
1) I've used floating point division to calculate the...
February 11, 2009 at 6:45 am
Viewing 15 posts - 301 through 315 (of 355 total)