Viewing 15 posts - 601 through 615 (of 1,439 total)
Is this what you want?
SELECT x.RowID, x.ParentID AS ChildParentID, x.ChildID AS GrandchildID
FROM @ParentChild x
WHERE EXISTS (SELECT * FROM @ParentChild y WHERE x.ParentID=y.ChildID)
April 23, 2012 at 9:16 am
You can also use a range table for this
INSERT INTO Ranges(MinVal,MaxVal)
SELECT 1,10 UNION ALL
SELECT 11,30 UNION ALL
SELECT 31,60
SELECT r.MinVal,
r.MaxVal,
...
April 20, 2012 at 3:37 am
kiran.rajenimbalkar (4/18/2012)
So please do...
April 18, 2012 at 7:40 am
See if this works
DECLARE @t TABLE(dq_org_dist_id INT, dq_rec_seq_nbr INT, dq_rec_start_cycle_ind INT)
INSERT INTO @t(dq_org_dist_id, dq_rec_seq_nbr, dq_rec_start_cycle_ind)
SELECT 1130, 22, 0 UNION ALL
SELECT 1130, 21, 1 UNION ALL
SELECT 1130, 20, 0 UNION ALL
SELECT...
April 18, 2012 at 6:06 am
Here's another way
WITH CTE AS (
SELECT DatePresent, Status,
DatePresent - ROW_NUMBER() OVER(ORDER BY DatePresent) AS rnDiff
FROM @Tab)
SELECT COUNT(*) AS Days,
...
April 13, 2012 at 1:04 pm
SQLMAIN (4/13/2012)
Will this work on SQLSERVER 2000?
Oops, my bad. Needs SQL Server 2005 or above.
April 13, 2012 at 9:36 am
Lots of ways of doing this
WITH CTE AS (
SELECT id,
age,
...
April 13, 2012 at 8:54 am
I think there's a discrepancy in your results, one of the 8890 should be 2500?
with cte as (
select p.myID, p.programID, p.stSVT, r.subjectCd, r.merit, h.noOfMinSubject,
...
April 13, 2012 at 3:12 am
SGT_squeequal (4/11/2012)
you can always use patindex to do the same.
select * from your table
where PATINDEX('%[^a-z,0-9]%',yourcollumm)>0
You don't need the comma in the regular expression
April 12, 2012 at 6:46 am
Guessing here
WITH CTE AS (
SELECT CASE WHEN AMOUNT>0 THEN FLAG1 ELSE FLAG2 END AS INBOUND,
CASE WHEN AMOUNT>0 THEN AMOUNT ELSE 0 END AS...
April 10, 2012 at 2:50 am
Does this help?
SELECT e.EMP_ID,
e.EMP_NAME,
e.EMP_ORGANIZATION,
e.EMP_DEPARTMENT,
...
March 30, 2012 at 9:15 am
Can you change the Calendar table? If so, you could add a computed persisted column " NextDay as dateadd(day, 1, Calendar.Date) "
Your join would then be
where OrderDate >=...
March 30, 2012 at 6:43 am
codebyo (3/30/2012)
Mark-101232 (3/30/2012)
with cte as (
select stageid,stagestatustypeid, applictaionid,
row_number() over(partition by applictaionid order by case when stagestatustypeid<>1 then 0 else 1 end,stageid desc) as...
March 30, 2012 at 6:14 am
with cte as (
select stageid,stagestatustypeid, applictaionid,
row_number() over(partition by applictaionid order by case when stagestatustypeid<>1 then 0 else 1 end,stageid desc) as rn
from test)
select...
March 30, 2012 at 4:13 am
Another way
SELECT TOP 1 WITH TIES
Company, Category, AcctgDate, Sequence, Amount
FROM #yourSampleData
ORDER BY Sequence DESC
March 29, 2012 at 9:29 am
Viewing 15 posts - 601 through 615 (of 1,439 total)