Skip to content
Advertisement

Tag: sql-server

Is there a way in SQL Server to sequence data by a group? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 4 months ago. Improve this question I have a table of data that has the following columns The data is going into a timeclock system. I am ultimately trying to find

Exclude Records Based on Criteria

I need to exclude the record: If a customer bought “Shoe” and “Hat” on the same day, exclude the record with “Hat”. If a customer bought “Shoe” and “Cloth” on the same day, exclude the record with “Cloth”. Here is the sample data: Here are the expected results: Answer Self join to your shoe criteria and make sure it is

How can I return the Maximum Letters for a particular location using SQL?

I have the following table: TicketNumber FullName Type ActionTaken CPZName DateReceived DateResponded A306250992 Robson de Souza letter Re-issue Notice Lannisport 06/09/2022 2022/10/06 10:35:48 A306180194 Rivaldo Vitor Borba Ferreira email Re-issue Notice Lannisport NULL 2022/01/06 12:07:05 A306054145 Ronaldo de Assis Moreira User Note Hold For 14 Days Jurassic Park 06/09/2022 2022/11/06 20:53:16 A307716063 Wayne Mark Rooney email Re-Offer Discount Atlantis NULL

SQL STUFF FOR XML with specific grouping

I’m working in SQL Server 2014, and I have the following simple data, which tracks calling history of users: I need to group the ACTIVITY values into one field, which effortlessly be done using the STUFF FOR XML function: However I need to conditionally group these, on the condition that there was more than a 90 day between the activity

Update Multiple Values in a SQL query based on row values

Is there a possible way only use SQL Update query to update July Data to August data? E.g. The Value of B in July should be updated to 12. Dimension Key is the primary key and Name is the “durable” key. CURSOR is allowed to use but not preferred. Answer You must join the table to itself to set different

How to use min() together with other column in SQL

I am building an application consisting of an SQL backend and several microservices that communicate with this backend. I am trying to get as little data as possible from the database over the wire so I am trying to fetch the exact records so I don’t have to start looping in the application logic. So this is the source table

Advertisement