Viewing 15 posts - 16 through 30 (of 1,438 total)
Here's another way
WITH CTE AS (
SELECT CityID, MonthID, LowTemp, HiTemp,ROW_NUMBER() OVER(PARTITION BY CityID ORDER BY MonthID) AS rn
FROM dbo.CityTemperature
WHERE LowTemp >= 64
)
SELECT m.MonthName, c.CityName
FROM...
August 31, 2022 at 5:43 pm
Maybe this?
select [User]
from mytable
group by [User]
having count(ProcessId) > count(distinct ProcessId);
August 2, 2022 at 11:10 am
This looks like a 'relational division' problem. Solution here not pretty but should work.
WITH Grps AS (
SELECT PartNumber,COUNT(*) AS GroupCount
FROM #parts
GROUP BY PartNumber
),
OrderedSrc AS (
SELECT PartNumber,PartValue,ROW_NUMBER() OVER(PARTITION...
July 25, 2022 at 1:22 pm
Mark Cowne wrote:That will match PageDefintions and PageDefintion giving a count of 2 for ID=2
Then can't you just change the search string to:
DECLARE @Find VARCHAR(MAX)='PageDefintion>'
?
Yes you could, that would work...
July 12, 2022 at 3:47 pm
You don't need all those REPLACE functions.
You can just do
DECLARE @Find VARCHAR(MAX)='PageDefintion'
SELECT
Detail_Form
,LEN(@Find) ,(LEN(Detail_Form)-LEN(REPLACE(Detail_Form,@Find,'')))/LEN(@Find) AS OccurrenceCount
FROM dbo.Table1
That will match PageDefintions and...
July 12, 2022 at 2:47 pm
Try this
select ID,detail_form,
(len(detail_form) - len(replace(replace(replace(detail_form,'<PageDefintion>','<>'),'<PageDefintion/>','</>'),'</PageDefintion>','</>'))) / len('PageDefintion') as PageDefintionCount
from mytable
July 12, 2022 at 10:11 am
Maybe this?
WITH CTE AS (
SELECT t.id,
j2.[key] AS field,
j2.value AS val,
row_number() over(partition by j2.[key] order...
July 1, 2022 at 11:11 am
DENSE_RANK() OVER(ORDER BY Id - register_sequence) AS seq_number
May 19, 2022 at 10:59 am
Small tweak to Phils code should do it
SELECT
q1.success
, q1.timestamp
, q1.date
, q1.base
, q1.unit
, q2.[key]...
April 27, 2022 at 1:23 pm
SELECT id,
MIN(Game_Time) AS Game_Start,
MAX(Game_Time) AS Game_END
FROM Game
GROUP BY id
ORDER BY id;
April 12, 2022 at 7:42 am
SELECT Date,ID,CHAR(ASCII('A') + (ROW_NUMBER() OVER(PARTITION BY Date ORDER BY ID) -1) % 3) AS Grp
FROM #s
ORDER BY Date,ID;
March 18, 2022 at 5:17 pm
@shogunSQL, this should work for you.
SELECT C.x.value('@Id', 'varchar(20)') as Id
,C.x.value('@ChapterName', 'varchar(20)') as ChapterName
,C.x.value('title[1]', 'varchar(100)') as Title
,C.x.value('concat(local-name(parent::*/parent::*),"\",local-name(parent::*),"\",local-name(.)) ', 'VARCHAR(1000)') AS [Path]
FROM @doc.nodes('ROOT/*/*/item') as C(x)
Another way
SELECT C.x.value('@Id', 'varchar(20)') as Id
,C.x.value('@ChapterName', 'varchar(20)') as ChapterName
,C.x.value('concat(local-name(parent::*/parent::*),"\",local-name(parent::*),"\",local-name(.)) ', 'VARCHAR(1000)') AS [Path]
FROM @doc.nodes('ROOT/*/*/item') as C(x)
February 25, 2022 at 4:00 pm
Deleted, wrong solution
January 20, 2022 at 1:36 pm
Not totally clear to me what you're asking for, maybe this?
with cte as (
select REF_NO,
n.x.value('Country[1]','varchar(30)') as Country,
...
October 22, 2021 at 10:49 am
Viewing 15 posts - 16 through 30 (of 1,438 total)
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy