Viewing 15 posts - 1,366 through 1,380 (of 1,496 total)
You can do it via a derived table:
SELECT
D.UM
,D.UM_DIV
,D.UM_DIV * D.QTYORD AS UnitNum
FROM (
SELECT S.UM
,S.QTYORD
,CASE S.um
WHEN 'ea' THEN 1
WHEN 'bx' THEN 10
ELSE 2 END AS UM_DIV
FROM Sales S ) D
November 10, 2006 at 10:16 am
You could try checking to see if any of the VIEWs point to a different server.
Also, as you do not seem to be using any aggregate functions, you could remove...
November 10, 2006 at 9:22 am
Using LEFT JOINs instead of INNER JOINs should solve your immediate problem. Age should always be calculated from DateOfBirth.
November 10, 2006 at 3:00 am
AMacKay,
You really need to redesign your tables so that the <Customers> table has a PRIMARY KEY called something like customerID int. Then you will need to add customerID as a...
November 9, 2006 at 11:36 am
The following should work but, like all triangular joins, if you have a lot of rows it would be better to use a cursor. Somewhere between 5000 and 10000 rows...
November 8, 2006 at 11:08 am
Do the following test with UPDLOCK:
1. Open Query Analyser twice selecting your db in both.
2. In one copy of QA run:
BEGIN TRAN
SELECT MIN(serialNo)
FROM card_pins WITH (UPDLOCK)
3. In the other copy...
November 6, 2006 at 8:52 am
I think you need to use either an UPDLOCK or an XLOCK. An UPDLOCK should be alright here.
SET XACT_ABORT ON
BEGIN TRANSACTION
SELECT @get_PIN = MIN(serialNo)
FROM card_pins WITH (UPDLOCK)
DELETE card_pins
WHERE serialNo= @get_PIN...
November 6, 2006 at 7:34 am
November 3, 2006 at 11:40 am
SELECT DATEADD(day, 0, DATEDIFF(day, CAST(0 as datetime) ,StartTime)) AS WorkDay
,COUNT(DISTINCT EmployeeID) AS MaxEmp
FROM TimeClock WITH (NOLOCK)
WHERE StartTime >= '20061001' AND EndTime < '20061101'
GROUP BY DATEADD(day, 0, DATEDIFF(day, CAST(0 as datetime)...
November 3, 2006 at 7:53 am
SELECT username
FROM usermaster
GROUP BY username
HAVING COUNT(*) > 1
November 3, 2006 at 6:14 am
What you want is unclear. If the rows returned are exact duplicates then replace SELECT with SELECT DISTINCT, otherwise you will need to decide which EUS_ID row to return. eg...
October 31, 2006 at 6:14 am
Maybe:
SELECT L.LOB_ID
,L.EUS_ID
,L.LOI_START_DATE
,L.LOI_END_DATE
,E.CTY_CODE
FROM learning_object_instances L
CROSS JOIN end_users E
JOIN (
SELECT L1.EUS_ID
FROM learning_object_instances L1
WHERE L1.LOI_START_DATE > '20060907'
GROUP BY L1.EUS_ID
HAVING COUNT(*) > 1 ) D
ON L.EUS_ID = D.EUS_ID
WHERE E.CTY_CODE = 'RU'
AND L.LOI_START_DATE > '20060907'
October 30, 2006 at 10:51 am
You may want to consider a different strategy:
1. Create views for all tables and views in your db along the lines of:
CREATE VIEW RO_YourTableName
AS
SELECT *
FROM YourTableName WITH (NOLOCK)
2. For your...
October 27, 2006 at 10:45 am
I think this can be done by creating a db that only consists of VIEWs of the tables in the main db. All the SELECTs in the VIEWs will have the...
October 27, 2006 at 9:42 am
Old style
select d1.InvNum,d1.ItemID,d2.ItemID
from InvDetl d1,InvDetl d2
where d1.InvNum=d2.InvNum and d1.ItemID<>d2.ItemID
New style
select d1.InvNum,d1.ItemID,d2.ItemID
from InvDetl d1
INNER join InvDetl d2 on d1.InvNum=d2.InvNum and d1.ItemID<>d2.ItemID
or
select d1.InvNum,d1.ItemID,d2.ItemID
from InvDetl d1
CROSS join InvDetl d2
WHERE d1.InvNum=d2.InvNum and...
October 27, 2006 at 6:26 am
Viewing 15 posts - 1,366 through 1,380 (of 1,496 total)