bfuchs
asked on
Sql question
Hi Experts,
I have the following two queries that would like to total the quantity of the records in the table, and for some reason I am missing some records.
Can someone explain where is the hole?
query1
P.S. there are only few records with no Day field entered or no TimeEntered, not enough to justify the discrepancy.
I have the following two queries that would like to total the quantity of the records in the table, and for some reason I am missing some records.
Can someone explain where is the hole?
query1
SELECT dbo_TimeSheet.Day, dbo_TimeSheet.TimeEntered, Format([TimeEntered],"mm/dd/yy") AS Expr1
FROM dbo_TimeSheet WHERE (((dbo_TimeSheet.Day) Is Not Null) AND ((dbo_TimeSheet.TimeEntered) Is Not Null) AND ((Format([TimeEntered],"mm/dd/yy"))<>CStr([day])));
query2SELECT dbo_TimeSheet.Day, dbo_TimeSheet.TimeEntered, Format([TimeEntered],"mm/dd/yy") AS Expr1
FROM dbo_TimeSheet WHERE (((dbo_TimeSheet.Day) Is Not Null) AND ((dbo_TimeSheet.TimeEntered) Is Not Null) AND ((Format([TimeEntered],"mm/dd/yy"))=CStr([day])));[/
P.S. there are only few records with no Day field entered or no TimeEntered, not enough to justify the discrepancy.
ASKER
Hi,
Total quantity of records from both queries together should equal the quantity of records in the table.
Total quantity of records from both queries together should equal the quantity of records in the table.
Define 'quantity', by the column name, and the aggregate you wish to perform (SUM, COUNT, etc.)
ASKER
I Have a table containing 2 columns
Day where date is entered
TimeEntered where date+time is entered
would like to see all those records that day column has a different date than the date portion in TimeEntered field.
This is the reason I am running those queries.
In order to ensure I am getting the correct results, I want to sum all those records that dates are the same with those that they are not the same, and get the total qty of records equal to what I have in the table.
Day where date is entered
TimeEntered where date+time is entered
would like to see all those records that day column has a different date than the date portion in TimeEntered field.
This is the reason I am running those queries.
In order to ensure I am getting the correct results, I want to sum all those records that dates are the same with those that they are not the same, and get the total qty of records equal to what I have in the table.
hi,
Kindly check date entered in the table is correct or not.
Kindly check date entered in the table is correct or not.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How many records returns each query? And how many records was you expecting to be returned?
Without some sample data it's hard for us to try to guess.
Without some sample data it's hard for us to try to guess.
ASKER
It is:
DateValue([TimeEntered]) AS DayOfTimeEntered,
/gustav
DateValue([TimeEntered]) AS DayOfTimeEntered,
/gustav
ASKER
Working well, thank you!
You are welcome!
/gustav
/gustav
Total ... what exactly? Sum of days, sum of time entered, ...
Both queries together, each one separately...