Viewing 15 posts - 1,381 through 1,395 (of 1,438 total)
It's not clear whether you want the keys concatenated into one column or left as separate columns.
This will concatentate the keys
SELECT a.RecordID,
(SELECT b.[Key]...
January 24, 2008 at 5:31 am
Another option is to use FOR XML PATH
SELECT m.Field1 AS Master,
STUFF((SELECT ','+c.Field1 AS "text()"
FROM Child...
January 24, 2008 at 5:01 am
Here's another way
WITH CTE AS (
SELECT SerialNumber,
ROW_NUMBER() OVER(ORDER BY SerialNumber) AS rn
FROM #yourtable)
SELECT s.SerialNumber+1 AS GapStart,
e.SerialNumber-1...
January 23, 2008 at 5:46 am
Try this
SELECT employer.statecode, COUNT(employer.statecode) AS ct
FROM employer
WHERE NOT EXISTS (SELECT *
FROM...
January 22, 2008 at 5:05 am
From what I can see, you'll need to use some dynamic SQL to select from @TBL.
Try replacing this
declare value cursor for
select report_code, max(REPORT_NO)
from @TBL
where person_code = @person_code
and...
January 21, 2008 at 9:47 am
Several ways to do this, here's one
WITH CTE AS(
SELECT Name, Factor1, Factor2,
ROW_NUMBER() OVER(PARTITION BY Name ORDER BY Factor1) as rn
FROM MyNames)
SELECT Name, Factor1, Factor2
FROM CTE
WHERE rn=1
January 19, 2008 at 11:52 am
Assuming you're using SQL Server 2005
SELECT
a.Acct_ID,
STUFF((SELECT ','+f.FlagTitle AS "text()"
FROM Flags f
WHERE a.Acct_ID = f.Acct_ID
ORDER BY f.FlagTitle
FOR XML PATH('')),1,1,'') AS Flags
FROM Accounts a
January 17, 2008 at 10:27 am
See if this helps
WITH ReducedAvetime AS
(SELECT origdate, duration_seconds, phoneuser, calltype
FROM #avetime a
WHERE NOT EXISTS (SELECT * FROM #avetime b
...
January 17, 2008 at 5:05 am
The subquery needs to reference phoneuser
select stime.phoneuser, avg(datediff(ss, stime.origdate, etime.origdate))
from #avetime stime
inner join #avetime etime
on stime.phoneuser = etime.phoneuser
and etime.origdate =...
January 16, 2008 at 2:50 am
Jeff,
Like the article. One suggestion though (not sure if this has already been raised in the comments - too many to look through), lots of people have problems posting XML,...
January 15, 2008 at 1:30 am
Brandon,
Few things...
Your XML hasn't appeared so it's not possible to tell what you're after. You'll need to repost.
FOR XML EXPLICIT requires an ORDER BY clause to work reliably.
If you are...
January 13, 2008 at 5:36 am
Can't see the significance of 'num' here, but try this anyway
SELECT s1.num,
s1.date1,
MIN(t1.date2) AS date2,
...
January 10, 2008 at 1:21 pm
Try this
create table mytable(ID_1 int, version int, Value varchar(10))
insert into mytable(ID_1,version,Value)
select 1, 1, 'value1' union all
select 1, 1, 'value2' union all
select 1, 2, 'value1' union all
select 1, 2, 'value2'...
January 10, 2008 at 9:28 am
Easier to remove a leading '/'
SELECT
FuelType = SUBSTRING(
CASE petrol WHEN 1 THEN '/petrol' ELSE '' END +
CASE diesel WHEN 1 THEN '/Diesel' ELSE '' END +
CASE E85 WHEN 1...
January 9, 2008 at 2:49 am
Viewing 15 posts - 1,381 through 1,395 (of 1,438 total)