Link to home
Start Free TrialLog in
Avatar of bfuchs
bfuchsFlag for United States of America

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
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])));

Open in new window

query2
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])));[/

Open in new window


P.S. there are only few records with no Day field entered or no TimeEntered, not enough to justify the discrepancy.
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

>total the quantity of the records in the table
Total ... what exactly?  Sum of days, sum of time entered, ...
Both queries together, each one separately...
Avatar of bfuchs

ASKER

Hi,
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.)
Avatar of bfuchs

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.
hi,

Kindly check date entered in the table is correct or not.
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of bfuchs

ASKER

@PortletPaul,
In middle of testing yours..

@Gustav,
See attached.
untitled.bmp
It is:

   DateValue([TimeEntered]) AS DayOfTimeEntered,

/gustav
Avatar of bfuchs

ASKER

Working well, thank you!
You are welcome!

/gustav