troubleshooting Question

SQL Query --> Only records where...

Avatar of Raahaugen
RaahaugenFlag for Denmark asked on
Microsoft ExcelSQL
8 Comments1 Solution385 ViewsLast Modified:
Hey Experts,

I have the following query, where I would like to include only one instance for every customernumber, namely the one with the earliest "bookingTime".

How do I extend the query to include this requirement?

Best regards, Raahaugen

SQL Query:

SELECT
             M.Id
            ,M.RebookedMeetingId
            ,M.BookingTime
            ,M.StartTime
            ,M.EndTime
            ,M.Status
            ,M.MeetingPurpose
            ,MT.Name as MeetingType
            ,M.CreatedBy as Booker
            ,TA.Initials as TiedAgent
            ,C.Name as Center
            ,CUS.CustomerNumber
            ,ADR.ZipCode

FROM "MBW-DB"."dbo"."Meeting" M
            join "MBW-DB"."dbo"."TiedAgent" TA on M.TiedAgentId = TA.id
            join "MBW-DB"."dbo"."MeetingType" MT on M.meetingTypeId = MT.id
            join "MBW-DB"."dbo"."Center" C on TA.centerId = C.Id
            join "MBW-DB"."dbo"."Customer" CUS on M.customerId = CUS.Id
            join "MBW-DB"."dbo"."Address" ADR on M.addressId = ADR.Id
           
WHERE M.MeetingPurpose = 'SalesMeeting'

order by BookingTime asc
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 8 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 8 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