Showing posts with label ran. Show all posts
Showing posts with label ran. Show all posts

Wednesday, March 7, 2012

Hourly Data

Hi,

I am trying to get total transactions for Cashiers on an hourly basis from my SQL Database. All the data is in the DB, but I have never ran a query that Counts transaction numbers per hour. I can get the total transactions per Cashier for the day, but not per hour.

Does someone have an answer for me?

Thanks

Lawrence

Assuming that you have a DATETIME column that indicates both the date and time that the row was inserted then you can use the example below as a template. The query will return a rowcount for each hour of the current day in which a row was inserted.

Chris

SELECT DATEPART(HOUR, MyTable.MyDateField) AS Hour, COUNT(*) AS [RowCount]

FROM MyTable

WHERE MyTable.MyDateField >= CAST(CONVERT(VARCHAR(11), GETDATE(), 106) AS DATETIME)

GROUP BY DATEPART(HOUR, MyTable.MyDateField)

|||

Thanks Chris,

I modified as needed and it worked perfect.

|||

Chris,

I was trying this query on a Weekly basis, but that did not work. How do I get it to work over a long period of time?

Thanks Chris

|||

Would you expect to see the results broken down by day, or would you want to see the total number of rows for the 3 o'clock to 4 o'clock period (for example) for all days represented by a single row?

e.g.

Either:

Day 1, Hour 3, 564

Day 2, Hour 3, 989

Day 3, Hour 3, 43

etc...

or a single row for hour 3 for all three days:

Hour 3, 1596

Chris

|||

Chris,

What I currently have is:

Cashier A: Hour :9 Total Transactions: 32

10 50

11 63 And so on. It would be nice if I could do this as follows:

Day 1: Hour :9 Total Transactions: 32

10 50

11 63

Day 2: Hour :9 Total Transactions: 32

10 50

11 63

Only if it is possible. I am using this in a crystal report, so I can group inside the report, but don't know how to get the data over a longer period than 1 day.

Thanks for the help Chris.

|||

You can simply extend the GROUP BY and SELECT lists to include the year, month and day - see the example below. @.MyDate is the earliest date on which you wish to report.

Chris

DECLARE @.MyDate DATETIME

SET @.MyDate = GETDATE()

SELECT DATEPART(YEAR, MyTable.MyDateField) AS [Year],

DATEPART(MONTH, MyTable.MyDateField) AS [Month],

DATEPART(DAY, MyTable.MyDateField) AS [Day],

DATEPART(HOUR, MyTable.MyDateField) AS [Hour],

COUNT(*) AS [RowCount]

FROM MyTable

WHERE MyTable.MyDateField >= CAST(CONVERT(VARCHAR(11), @.MyDate, 106) AS DATETIME)

GROUP BY DATEPART(YEAR, MyTable.MyDateField),

DATEPART(MONTH, MyTable.MyDateField),

DATEPART(DAY, MyTable.MyDateField),

DATEPART(HOUR, MyTable.MyDateField)

ORDER BY 1, 2, 3, 4

|||This is great! Thanks Chris!! This was very helpfull!

Friday, February 24, 2012

Hotfix contents

Hi,
Does anyone know a source for the contents of the SQL Hotfix which updates SQL2000 to version 8.00.919? I have the hotfix and ran it on a development SQL server but I cannot find a definitive list of the contents. I've been given one article from microsof
t (http://support.microsoft.com/default...b;en-us;837957) but I believe there are more fixes contained therein (I'd hope so at >17mb). I couldn't find anything on knowledge base or technet.
Thanks
DaveK
http://www.sqlporn.co.uk
If you look at the list of files in 837957, I can certainly see that the
updated files add up to at least 17mb uncompressed.
Keep in mind that a certain patch level does not contain just that patch,
but it is cumulative (so that if you thought you needed to apply 918, for
example, you wouldn't have to because it's already there). I keep a list of
the hotfixes at http://www.aspfaq.com/2160 so you can browse through those
other KBs to see what other symptoms were fixed between build 760 and build
919.
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"DaveK" <anonymous@.discussions.microsoft.com> wrote in message
news:5BD0BDC4-A4D1-422B-9785-1BF224E167EF@.microsoft.com...
> Hi,
> Does anyone know a source for the contents of the SQL Hotfix which updates
SQL2000 to version 8.00.919? I have the hotfix and ran it on a development
SQL server but I cannot find a definitive list of the contents. I've been
given one article from microsoft
(http://support.microsoft.com/default...b;en-us;837957) but I
believe there are more fixes contained therein (I'd hope so at >17mb). I
couldn't find anything on knowledge base or technet.
> Thanks
> DaveK
> http://www.sqlporn.co.uk

Hotfix contents

Hi
Does anyone know a source for the contents of the SQL Hotfix which updates SQL2000 to version 8.00.919? I have the hotfix and ran it on a development SQL server but I cannot find a definitive list of the contents. I've been given one article from microsoft (http://support.microsoft.com/default.aspx?scid=kb;en-us;837957) but I believe there are more fixes contained therein (I'd hope so at >17mb). I couldn't find anything on knowledge base or technet
Thank
Dave
http://www.sqlporn.co.ukIf you look at the list of files in 837957, I can certainly see that the
updated files add up to at least 17mb uncompressed.
Keep in mind that a certain patch level does not contain just that patch,
but it is cumulative (so that if you thought you needed to apply 918, for
example, you wouldn't have to because it's already there). I keep a list of
the hotfixes at http://www.aspfaq.com/2160 so you can browse through those
other KBs to see what other symptoms were fixed between build 760 and build
919.
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"DaveK" <anonymous@.discussions.microsoft.com> wrote in message
news:5BD0BDC4-A4D1-422B-9785-1BF224E167EF@.microsoft.com...
> Hi,
> Does anyone know a source for the contents of the SQL Hotfix which updates
SQL2000 to version 8.00.919? I have the hotfix and ran it on a development
SQL server but I cannot find a definitive list of the contents. I've been
given one article from microsoft
(http://support.microsoft.com/default.aspx?scid=kb;en-us;837957) but I
believe there are more fixes contained therein (I'd hope so at >17mb). I
couldn't find anything on knowledge base or technet.
> Thanks
> DaveK
> http://www.sqlporn.co.uk

Hotfix contents

Hi,
Does anyone know a source for the contents of the SQL Hotfix which updates S
QL2000 to version 8.00.919? I have the hotfix and ran it on a development SQ
L server but I cannot find a definitive list of the contents. I've been give
n one article from microsof
t (http://support.microsoft.com/defaul...kb;en-us;837957) but I bel
ieve there are more fixes contained therein (I'd hope so at >17mb). I couldn
't find anything on knowledge base or technet.
Thanks
DaveK
http://www.sqlporn.co.ukIf you look at the list of files in 837957, I can certainly see that the
updated files add up to at least 17mb uncompressed.
Keep in mind that a certain patch level does not contain just that patch,
but it is cumulative (so that if you thought you needed to apply 918, for
example, you wouldn't have to because it's already there). I keep a list of
the hotfixes at http://www.aspfaq.com/2160 so you can browse through those
other KBs to see what other symptoms were fixed between build 760 and build
919.
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"DaveK" <anonymous@.discussions.microsoft.com> wrote in message
news:5BD0BDC4-A4D1-422B-9785-1BF224E167EF@.microsoft.com...
> Hi,
> Does anyone know a source for the contents of the SQL Hotfix which updates
SQL2000 to version 8.00.919? I have the hotfix and ran it on a development
SQL server but I cannot find a definitive list of the contents. I've been
given one article from microsoft
(http://support.microsoft.com/defaul...kb;en-us;837957) but I
believe there are more fixes contained therein (I'd hope so at >17mb). I
couldn't find anything on knowledge base or technet.
> Thanks
> DaveK
> http://www.sqlporn.co.uk