I have two tables with these columns:
Table 1:
ID , INT
NAME, NVARCHA
ROLL, INT
Table 2:
ID, INT
NAME_ID, INT
REAL_DATE, Date
H7_00, BIT
H8_00, BIT
I want to get a list of names of those that H7_00 is true like this, for a period of 3 months.
Real_Date | Name| Name | Name | Name | Name | Name | Name |Name |Name |Name |Name
Real_Date | Name | Name |
Real_Date | Name| Name | Name | Name
Real_Date | Name | Name | Name | Name |Name| Name | Name | Name
The following is what I tried
SELECT
Hours.Real_Date, Person.Name ,Person.Role
FROM
Person
INNER JOIN
Hours ON Hours.P_ID = Person.ID
WHERE
(Hours.Real_Date >= getDate())
AND
(Hours.Real_Date <= getDate() + 90)
(Hours.H7_00 = 1 AND Hours.H7_00_Free = 1)
AND
(Person.Role = 1)
ORDER BY
Real_Date, Name
This is what I got
2013-12-12 AAAA 1
2013-12-12 BBBB 1
2013-12-12 CCCC 1
If anyone has a solution I would appreciate it very,
And thanks in advance for reply