troubleshooting Question

Query to List of non duplicate values by date

Avatar of johnnyg123
johnnyg123Flag for United States of America asked on
Microsoft SQL Server
9 Comments1 Solution108 ViewsLast Modified:
I have a sample table with the following data

OrderDate	Month	itemid
2018-03-05	March	110
2018-03-05	March	112
2018-03-06	March	112
2018-03-06	March	113
2018-03-07	March	113
2018-04-05	April	110
2018-04-05	April	112
2018-04-06	April	112
2018-04-06	April	115
2018-04-07	April	113


INSERT INTO [dbo].[Orderinfo]
           ([OrderDate]
           ,[Month]
           ,[itemid])
     VALUES
        	
('2018-03-05',	'March',	'110')


INSERT INTO [dbo].[Orderinfo]
           ([OrderDate]
           ,[Month]
           ,[itemid])
     VALUES
        	
('2018-03-05',	'March',	'112')


INSERT INTO [dbo].[Orderinfo]
           ([OrderDate]
           ,[Month]
           ,[itemid])
     VALUES
        	
('2018-03-06',	'March',	'112')

INSERT INTO [dbo].[Orderinfo]
           ([OrderDate]
           ,[Month]
           ,[itemid])
     VALUES
        	
('2018-03-06',	'March',	'113')


INSERT INTO [dbo].[Orderinfo]
           ([OrderDate]
           ,[Month]
           ,[itemid])
     VALUES
        	
('2018-03-07',	'March',	'113')



-----------------------------------------------


INSERT INTO [dbo].[Orderinfo]
           ([OrderDate]
           ,[Month]
           ,[itemid])
     VALUES
        	
('2018-04-05',	'April',	'110')


INSERT INTO [dbo].[Orderinfo]
           ([OrderDate]
           ,[Month]
           ,[itemid])
     VALUES
        	
('2018-04-05',	'April',	'112')


INSERT INTO [dbo].[Orderinfo]
           ([OrderDate]
           ,[Month]
           ,[itemid])
     VALUES
        	
('2018-04-06',	'April',	'112')

INSERT INTO [dbo].[Orderinfo]
           ([OrderDate]
           ,[Month]
           ,[itemid])
     VALUES
        	
('2018-04-06',	'April',	'115')


INSERT INTO [dbo].[Orderinfo]
           ([OrderDate]
           ,[Month]
           ,[itemid])
     VALUES
        	
('2018-04-07',	'April',	'113')
Trying to write a query to get of unique order ids by month

Definition of unique order id is that it does not appear in any day of month

given sample data

I am looking for the following output

Month    items

march      3
April          1

Ideas ???
ASKER CERTIFIED SOLUTION
G Trurab Khan
Snr. Development Manager

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros