Thank you for taking care of me.
I would like to get data with the same ID, date, and serial number, code 1234 and 1235.
ID Date Serial Number Code
120060223 1 1234
sql server 2008 R2
I would appreciate it if you could tell me how to obtain it on linq as well.
Thank you for your cooperation.
First of all, there is a condition that the ID, date, and serial number are the same, so you need to group them together.
To determine if each group meets the requirements, I think it would be better to limit the code with
WHERE code IN('1234', '1235'), and then check the number of each group with
COUNT(DISTINCT code) to obtain two types of code.
Therefore, the SQL to retrieve the group key is as follows:
You can use this SELECT statement as a subquestion and combine it with
EXISTS to achieve the desired SQL.
For example, using
It will look like this.
Implementation with LINQ is possible with the same policy.
© 2022 OneMinuteCode. All rights reserved.