Home>

I have two tables, one with the types of games, and the second with the circles. First GameType with columns: Gametypeid, Gamename, IsActive. Second Draw: Drawid, Gametypeid, Drawno, Drawdate.

How to make a request to compile these two tables and get only IsActive= 1, Drawno, Drawdate -only one next game for each GameType

Show CREATE TABLE, and not verbally describe the structure. Give an example of data (INSERT INTO) and the required response for this data. With explanations, why this is.

Akina2021-08-19 03:01:08
  • Answer # 1

    while it turned out only

    Select * from Gametype
    Inner Join.
    (Select Draw.Gametypeid AS GameID, MIN (draw.drawdate) AS Drawdate
    From Draw.
    Where draw.drawdate >
    = Getdate ()
    Group by Draw.GameTypeid) As New On New.GameID= GameType.GameTypeID
    
  • Answer # 2

    while it turned out only

    Select * from Gametype
    Inner Join.
    (Select Draw.Gametypeid AS GameID, MIN (draw.drawdate) AS Drawdate
    From Draw.
    Where draw.drawdate >
    = Getdate ()
    Group by Draw.GameTypeid) As New On New.GameID= GameType.GameTypeID