Viewing 15 posts - 76 through 90 (of 113 total)
Try:
SELECT
FormKey,
CASE
WHEN MIN(Flag1) = 129 AND MAX(Flag1) = 130 AND COUNT(Flag1) = 2 THEN 135
ELSE MAX(Flag1)
END AS Flag1,
CASE
WHEN MIN(Flag2) = 129 AND MAX(Flag2) = 130 AND COUNT(Flag2)...
November 12, 2013 at 11:15 am
Have you considered using the EXISTS operator instead IN and avoid the concatenation?
...
AND NOT EXISTS (
SELECT *
FROM MHGROUP.DOC_ACCESS AS A
WHERE A.DOCNUM = DM.DOCNUM AND A.USER_GP_ID = G.USER_GP_ID
);
I wonder if you...
November 8, 2013 at 12:16 pm
I tried identifing first the orders with an item not in #BofM and then did the intersect with orders matching items in #BofM but having more components. The intersect simulates...
November 8, 2013 at 11:56 am
The problem you are trying to solve is known as "Finding Islands" and you can read more about it in the last book from Itzik Ben-Gan about T-SQL Querying.
The idea...
November 8, 2013 at 9:48 am
Just remember that a table has no predefined order for the rows. Can you provide a column or group of columns that help us to identify the chronological order of...
November 8, 2013 at 8:31 am
Instead using:
insert into T1 (c1, c2)
select 1, 2;
insert into T1 (c1, c2)
select 3, 4;
or
insert into T1 (c1, c2)
select c1, c2
from (
select 1, 2;
union all
select 3, 4
) as Q(c1, c2)
use just...
November 4, 2013 at 11:03 am
If the number of elements per ID is always 3 then you can pivot, group by yhe pivoted columns and count the distinct IDs.
SET NOCOUNT ON;
USE tempdb;
GO
CREATE TABLE trial
(
ID...
October 26, 2013 at 4:00 pm
John,
Your thinking is correct but it get complicated depending on which sub-branch was specified as part of the statement. There is a comprehensive list in this article / topic in...
October 25, 2013 at 8:00 am
You are right and that was a bad choice from my side so I apologize for that.
The way I see this warning is that the "unexpected" is more related to...
October 24, 2013 at 7:30 pm
Here is a small script and the result from them is not the same based on the suggestions in BOL.
Merge both tables but update column [c2] in the target only...
October 24, 2013 at 7:54 am
It will be helpful having DDL, sample data, an expected result. That way we do not have to guess column names, data types, etc.
Help us to be able to help...
October 22, 2013 at 11:19 am
What should we report back if these conditions take place:
1 - The employee in question is a director?
2 - There are several directors at the same level?
Anyway, the idea would...
October 21, 2013 at 11:12 am
The example is using "ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING". Just two values are possible, so why are you adding three values?
-- wrong
280 1 1,352,577.13 2005 4502152.27 (1,352,577.13+1,573,012.94+1,576,562.20)=>different conclusion
283...
October 16, 2013 at 11:58 am
Try:
With C1 as (
Select id, color, row_number() over(partition by id order by rank) as rn
From carinfo
)
Update A
Set A.color = C1.color
From cars as A inner join C1 on A.id = C1.id...
October 8, 2013 at 6:34 pm
Since you are just looking at characters before the first ".", then you could use something like:
SELECT
*
FROM
(
...
October 7, 2013 at 9:39 am
Viewing 15 posts - 76 through 90 (of 113 total)