Create ext. Attribute in tab. BOOK or you can sort in the request as something? Tried to unite the BOOK and ISSUE nothing sensible came out ...

select Π½Π°Π·Π²Π°Π½ΠΈΠ΅, count(ΠšΠΠ˜Π“Π.ΠΊΠΎΠ΄_ΠΊΠ½ΠΈΠ³ΠΈ) as ΠΊΠΎΠ»_Π²ΠΎ from dbo.Π’Ρ‹Π΄Π°Ρ‡Π° INNER JOIN dbo.Книга ON dbo.Π’Ρ‹Π΄Π°Ρ‡Π°.ΠΊΠΎΠ΄_ΠΊΠ½ΠΈΠ³ΠΈ = dbo.Книга.ΠΊΠΎΠ΄_ΠΊΠ½ΠΈΠ³ΠΈ where Π΄Π°Ρ‚Π°_Π²ΠΎΠ·Π²Ρ€Π°Ρ‚Π° < getdate() and Ρ„Π°ΠΊΡ‚_Π²ΠΎΠ·Π²Ρ€Π°Ρ‚ is not null GROUP BY Π½Π°Π·Π²Π°Π½ΠΈΠ΅ 

DB diagram

  • one
    Add your attempt code to the question. Just without him, he looks in the style of "do it for me." No offense. - Streletz
  • The essence of the question is incomprehensible. Are you designing a database or trying to create a query using a ready-made database? If you design, then archtiektura so-so, if you create a request, it is unclear what causes the question. - AK ♦
  • And, do not duplicate tags in the header. Read more here - AK ♦
  • one
    @egorusakov you better spend time and add a description of the task with all the assumptions and limitations, so that it would be clear how detailed you are going to work on the subject area, otherwise it is very difficult to find flaws in your architecture. - Serge Nazarenko
  • one
    and better start a discussion in the chat - Serge Nazarenko

1 answer 1

One book can be in several points of issue and one point of issue can contain several books. Here the NN link is needed. Now the book is assigned a point of issue, and there is no information about the remains of the books. Make an intermediate table that implements NN with fields:

 ΠΊΠΎΠ΄_ΠΊΠ½ΠΈΠ³ΠΈ ΠΊΠΎΠ΄_ΠΏΡƒΠ½ΠΊΡ‚Π° остаток