March 6, 2024 at 5:42 pm
OK. What is your question?
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
March 6, 2024 at 7:06 pm
Do either of these give you what you need?
--ONE ROW PER NAME WITH COUNT
SELECT firstlastmerged,
COUNT(firstlastmerged) AS Cnt
FROM dbo.YourTable
GROUP BY firstlastmerged
--REPEATED NAMES WITH REPEATED COUNT
SELECT firstlastmerged,
COUNT(*) OVER (PARTITION BY firstlastmerged) AS Cnt
FROM dbo.YourTable
March 7, 2024 at 6:00 am
Hi All,
I have a data in column A in where in need to achieve the count which I have mentioned in column B. Please find the attached excel dataset for reference.
Thanks
A lot of us won't open attached spreadsheets for many reasons. Please see the article at the first link in my signature line below for the preferred method of using readily consumable data.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 3, 2024 at 2:17 am
Here is the query to insert the data in table.
-- Step 1: Create the table
CREATE TABLE sat_temp (
Domain NVARCHAR(255),
[Required Result] INT
);
-- Step 2: Insert the data
INSERT INTO sat_temp (Domain, [Required Result])
VALUES
('AlissaParteemarvin.com', 10),
('AlissaParteemarvin.com', 10),
('AlissaParteemarvin.com', 10),
('AlissaParteemarvin.com', 10),
('AlissaParteemarvin.com', 10),
('AlissaParteemarvin.com', 10),
('AlissaParteemarvin.com', 10),
('AlissaParteemarvin.com', 10),
('AlissaParteemarvin.com', 10),
('AlissaParteemarvin.com', 10),
('DanielOoiocbc.com', 5),
('DanielOoiocbc.com', 5),
('DanielOoiocbc.com', 5),
('DanielOoiocbc.com', 5),
('DanielOoiocbc.com', 5),
('GargPrashantocbc.com', 1),
('GaryKeildurangotrain.com', 2),
('GaryKeildurangotrain.com', 2),
('GuSuyangsdic.com.cn', 2),
('GuSuyangsdic.com.cn', 2);
Need a query to get the result which I had mentioned in column [Required Result]
July 3, 2024 at 8:22 am
If you're going to create a temp table, at least make it temporary!
DROP TABLE IF EXISTS #sat_temp;
CREATE TABLE #sat_temp
(
Domain NVARCHAR(255)
);
INSERT #sat_temp
(
Domain
)
VALUES
('AlissaParteemarvin.com')
,('AlissaParteemarvin.com')
,('AlissaParteemarvin.com')
,('AlissaParteemarvin.com')
,('AlissaParteemarvin.com')
,('AlissaParteemarvin.com')
,('AlissaParteemarvin.com')
,('AlissaParteemarvin.com')
,('AlissaParteemarvin.com')
,('AlissaParteemarvin.com')
,('DanielOoiocbc.com')
,('DanielOoiocbc.com')
,('DanielOoiocbc.com')
,('DanielOoiocbc.com')
,('DanielOoiocbc.com')
,('GargPrashantocbc.com')
,('GaryKeildurangotrain.com')
,('GaryKeildurangotrain.com')
,('GuSuyangsdic.com.cn')
,('GuSuyangsdic.com.cn');
SELECT st.Domain
,ct = COUNT (st.Domain)
FROM #sat_temp st
GROUP BY st.Domain;
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
July 4, 2024 at 9:05 am
Did either of Ed B's solutions work for you?
If not, could you post what the output should look like using the test data you've provided? I'm also not sure what your request actually is.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply