Wednesday, March 7, 2012

Query Calculated Member - Member Properties

I have an urgent problem with some queries including calculated members where I want to filter by properties..

I have rewriten my query to show my issue on the Adventure Works Database.

Code Snippet

with

member [Account].[Accounts].[TEST] as 0

/* create a new query calculated member in the hierarchy */

select

{} on columns,

{

filter(

{

descendants([Account].[Accounts].&[1], 2)

,[Account].[Accounts].[TEST]

/* use the new calculated member */

/* comment out the calc member to see successfull execution */

},

[Account].[Accounts].CurrentMember.Properties("Account Type")="Assets"

/* filter by a member property which does not exists on the query calculated member - error */

)

}

dimension properties

[Account].[Accounts].[Account Type],

[Account].[Accounts].[Account Number],

[Account].[Accounts].[Accounts]

on rows

from

[Adventure Works]

I create a calcuated meber - and then I want to use this in a filter by member property. The Server always raises the error that the property does not exists.

How to solve this error?

The Documentation http://technet.microsoft.com/en-us/library/ms146017.aspx specify a possiblity to specify the property for the member - but I was not able to this - like documented It has no effect.

I need some urgent Help, HANNES

If you want filter to remove the calculated member then use stripcalculatedmembers function to remove all calculated members from the 1st argument. If you want filter to retain the calculated member then use the iserror function like below:

with

member [Account].[Accounts].[TEST] as 0

/* create a new query calculated member in the hierarchy */

select

{} on columns,

{

filter(

{

descendants([Account].[Accounts].&[1], 2)

,[Account].[Accounts].[TEST]

},

iserror([Account].[Accounts].CurrentMember.Properties("Account Type")) or [Account].[Accounts].CurrentMember.Properties("Account Type")="Assets"

/* filter by a member property which does not exists on the query calculated member - error */

)

}

dimension properties

[Account].[Accounts].[Account Type],

[Account].[Accounts].[Account Number],

[Account].[Accounts].[Accounts]

on rows

from

[Adventure Works]

|||

Hi,

my question - how do I proper specify a mdx property in the query calculated member.

I do not want to catch errors - nor produce errors - howto specifiy the property value in the query.

The documentation at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2126305&SiteID=1 mentions a syntax, but I can not get it work.

If I properly read the doc I would write it like

Code Snippet

with

member [Account].[Accounts].[TEST] as 0 ([Account].[Accounts].[Account Type]="Assets")

/* create a new query calculated member in the hierarchy */

select

But it dos not work.

Any ideas howto write?

HANNES

|||Calculated members don't support custom member properties. The document you mentioned shows you how to use pre-defined member properties, such as FORMAT_STRING, for calculated members.

Query Calculated Member - Member Properties

I have an urgent problem with some queries including calculated members where I want to filter by properties..

I have rewriten my query to show my issue on the Adventure Works Database.

Code Snippet

with

member [Account].[Accounts].[TEST] as 0

/* create a new query calculated member in the hierarchy */

select

{} on columns,

{

filter(

{

descendants([Account].[Accounts].&[1], 2)

,[Account].[Accounts].[TEST]

/* use the new calculated member */

/* comment out the calc member to see successfull execution */

},

[Account].[Accounts].CurrentMember.Properties("Account Type")="Assets"

/* filter by a member property which does not exists on the query calculated member - error */

)

}

dimension properties

[Account].[Accounts].[Account Type],

[Account].[Accounts].[Account Number],

[Account].[Accounts].[Accounts]

on rows

from

[Adventure Works]

I create a calcuated meber - and then I want to use this in a filter by member property. The Server always raises the error that the property does not exists.

How to solve this error?

The Documentation http://technet.microsoft.com/en-us/library/ms146017.aspx specify a possiblity to specify the property for the member - but I was not able to this - like documented It has no effect.

I need some urgent Help, HANNES

If you want filter to remove the calculated member then use stripcalculatedmembers function to remove all calculated members from the 1st argument. If you want filter to retain the calculated member then use the iserror function like below:

with

member [Account].[Accounts].[TEST] as 0

/* create a new query calculated member in the hierarchy */

select

{} on columns,

{

filter(

{

descendants([Account].[Accounts].&[1], 2)

,[Account].[Accounts].[TEST]

},

iserror([Account].[Accounts].CurrentMember.Properties("Account Type")) or [Account].[Accounts].CurrentMember.Properties("Account Type")="Assets"

/* filter by a member property which does not exists on the query calculated member - error */

)

}

dimension properties

[Account].[Accounts].[Account Type],

[Account].[Accounts].[Account Number],

[Account].[Accounts].[Accounts]

on rows

from

[Adventure Works]

|||

Hi,

my question - how do I proper specify a mdx property in the query calculated member.

I do not want to catch errors - nor produce errors - howto specifiy the property value in the query.

The documentation at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2126305&SiteID=1 mentions a syntax, but I can not get it work.

If I properly read the doc I would write it like

Code Snippet

with

member [Account].[Accounts].[TEST] as 0 ([Account].[Accounts].[Account Type]="Assets")

/* create a new query calculated member in the hierarchy */

select

But it dos not work.

Any ideas howto write?

HANNES

|||Calculated members don't support custom member properties. The document you mentioned shows you how to use pre-defined member properties, such as FORMAT_STRING, for calculated members.

Query Cache?

Does SQL Server have a query cache similar to mysql, whereas the query
result is cached, if the table has not been changed?

If so, please refer me to more info.

Thanks.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/General-Dis...pict170423.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=571428steve (UseLinkToEmail@.dbForumz.com) writes:
> Does SQL Server have a query cache similar to mysql, whereas the query
> result is cached, if the table has not been changed?

SQL Server maintains a cache, but certainly not with canned results for a
queries. In a OLTP system, many tables are frequently updated, so such the
likelyhood the of the same query yielding the same result twice is not that
fantastic. And for that matter, the likelyhood of the same query reappering
with the exactly the same parameters is not that extreme either. It is also
worth to keep in mind that most queries refers to more than one table.

What SQL Server has in its cache are recently accessed data pages, as well
as query plan for recently submitted queries and invoked stored procedure.
This makes it possible to retrieve the result of a query without accessing
the disk for frequently accessed tables. Note here that this cache works
better, the bigger it is. Thus, spending cache on less usful information,
such as canned query results, may have adverse results on performance.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Saturday, February 25, 2012

Query by year group by total students sort by total for each county

I haven't a clue how to accomplish this.
All the data is in one table. The data is stored by registration date
and includes county and number of students brokne out by grade.

Any help appreciated!

RobSomething like this, maybe:

SELECT county, YEAR(registration_date), SUM(num_students) AS tot_students
FROM Students
GROUP BY county, YEAR(registration_date)
ORDER BY county, tot_students

If you need more help please post DDL (CREATE TABLE statement) for the
table, including keys and constraints.

--
David Portas
----
Please reply only to the newsgroup
--|||the_ainbinders@.yahoo.com (Rob) wrote in message news:<14be79e4.0312010657.8573393@.posting.google.com>...
> I haven't a clue how to accomplish this.
> All the data is in one table. The data is stored by registration date
> and includes county and number of students brokne out by grade.
> Any help appreciated!
> Rob

Here's the CREATE TABLE

CREATE TABLE [dbo].[EdSales] (
[FName] [nvarchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[LName] [nvarchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[OrgName] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Addr1] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Addr2] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[City] [nvarchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[County] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[State] [nvarchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Zip] [nvarchar] (20) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Phone] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[extension] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Fax] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Email] [nvarchar] (80) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[DOV] [datetime] NULL ,
[grade1] [numeric](10, 0) NULL ,
[grade2] [numeric](10, 0) NULL ,
[grade3] [numeric](10, 0) NULL ,
[grade4] [numeric](10, 0) NULL ,
[grade5] [numeric](10, 0) NULL ,
[grade6] [numeric](10, 0) NULL ,
[grade7] [numeric](10, 0) NULL ,
[grade8] [numeric](10, 0) NULL ,
[grade9] [numeric](10, 0) NULL ,
[grade10] [numeric](10, 0) NULL ,
[grade11] [numeric](10, 0) NULL ,
[grade12] [numeric](10, 0) NULL ,
[grade13] [numeric](10, 0) NULL ,
[grade14] [numeric](10, 0) NULL ,
[grade15] [numeric](10, 0) NULL ,
[grade16] [numeric](10, 0) NULL ,
[grade17] [numeric](10, 0) NULL ,
[comments] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[dateEntered] [datetime] NULL ,
[result] [numeric](18, 0) NULL ,
[ConfirmNum] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
[visible] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

ALTER TABLE [dbo].[EdSales] WITH NOCHECK ADD
CONSTRAINT [PK_EdSales_1] PRIMARY KEY CLUSTERED
(
[ConfirmNum]
) WITH FILLFACTOR = 90 ON [PRIMARY]
GO

ALTER TABLE [dbo].[EdSales] WITH NOCHECK ADD
CONSTRAINT [DF_EdSales_visible] DEFAULT ('y') FOR [visible]
GO|||Your table design has some problems: Non-normalised repeating group of
Grades; No natural primary key; Too many NULLable columns (if every column
can be NULL then why would you have a row in the table anyway!). This query
would be a lot simpler if you fixed these things.

SELECT county, YEAR(dateentered) AS year_entered,
SUM(
COALESCE(grade1,0)+
COALESCE(grade2,0)+
COALESCE(grade3,0)+
COALESCE(grade4,0)+
COALESCE(grade5,0)+
COALESCE(grade6,0)+
COALESCE(grade7,0)+
COALESCE(grade8,0)+
COALESCE(grade9,0)+
COALESCE(grade10,0)+
COALESCE(grade11,0)+
COALESCE(grade12,0)+
COALESCE(grade13,0)+
COALESCE(grade14,0)+
COALESCE(grade15,0)+
COALESCE(grade16,0)+
COALESCE(grade17,0))
AS tot_students
FROM EdSales
GROUP BY county, YEAR(dateentered)

--
David Portas
----
Please reply only to the newsgroup
--|||"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message news:<_dGdnR8i6ZJR9VGiRVn-jg@.giganews.com>...
> Your table design has some problems: Non-normalised repeating group of
> Grades; No natural primary key; Too many NULLable columns (if every column
> can be NULL then why would you have a row in the table anyway!). This query
> would be a lot simpler if you fixed these things.
> SELECT county, YEAR(dateentered) AS year_entered,
> SUM(
> COALESCE(grade1,0)+
> COALESCE(grade2,0)+
> COALESCE(grade3,0)+
> COALESCE(grade4,0)+
> COALESCE(grade5,0)+
> COALESCE(grade6,0)+
> COALESCE(grade7,0)+
> COALESCE(grade8,0)+
> COALESCE(grade9,0)+
> COALESCE(grade10,0)+
> COALESCE(grade11,0)+
> COALESCE(grade12,0)+
> COALESCE(grade13,0)+
> COALESCE(grade14,0)+
> COALESCE(grade15,0)+
> COALESCE(grade16,0)+
> COALESCE(grade17,0))
> AS tot_students
> FROM EdSales
> GROUP BY county, YEAR(dateentered)

Well, I am a newbie at this sort of a thing. So, any pointers to
useful info on the diffiencies you mention are appreciated.

QUERY BY USER

I have a datagrid with rows that pertain to multiple users. I want to
write a query statement so that whomever the CURRENT logged-in
user is, he can go to the datagrid page and it will show ONLY rows
that pertain to him (programmatic security). To accomplish this,
I have a column in the datatable that references each user's
username. So I need a query statement that will compare the table's
'username' column to the current logged-in user. Something like...

SELECT... FROM [VendorEquipment]
WHERE [UserName] = Context.Current.User.Name

...or something like this. Question is, can someone help on how to
syntax this. Also, do I need anything special in the login form or in
web.config to 'pave the way' for this query to work.

Thx much.
Reid C.after a successfull login,you can store the username in sessions...|||Thanks for the reply...but I am a novice and will probably need more to clear up
the picture...can you suggest how I can syntax my SELECT command to accomplish
the above-stated objective and is there something I need to do via sessions to
enable this--and where would I do that?

Thx much.
Reid C.|||i believe you are checking for user authorization when the user logs in right ?

just put the username into session after the validation is successfull


session("username")=username

and frm any page
you can get it back as

dim uname as string
uname=session("username")

so when you query the db for the records you can do something like

strsql=select * From table where username='" & uname & "'"

and bind the datagrid.

HTH|||Thanks again...this sounds like what I'm looking for...just two
more questions due to my relative inexperience:

1) the statement: session("username")=username
you suggested...does that need to be in the login form
like in the "sub loginBtn_click" subroutine? and if so where in
the subroutine does it need to go...is the placement of the
statement critical?

2) is "username" interchangeable in this operation with "userid" ?
because I have written my registration form and login with a
"userid" instead of a "username"...but I will change this if it is
important to have "username" for forms authentication.

Thx.
Reid C.|||yep you can have any variable in session you want..username,userid...doesnt matter.
right after you check the userid with the password and if the query returns as a valid user, store the userid in sessions...and you should be able to access it frm any page...

HTH|||Thank you ...do I place the session stmt in global.asax?

like this, for instance:

Sub Session_OnStart()
Session("userId")=userId
End Sub


?

Thx.
Reid C.|||no...you put it in ur login.aspx where ever you validate the authenticity of the user...|||o.k., thanks again, ...but I am a complete novice and have been building pages
using WebMatrix, so sorry to be dense...but do I place the "session..." statement
in the "Function GetUser..." or in my "Sub LoginBtn_click..." subroutine, or after
that and right before the </script> tag ? I know placement of this statement is
important, I just don't know where?

Thx again.
Reid C.|||if you post your code for the login page..i can tell you where to place it...|||Thanks again for all your help...here is the code for the login (minus the html) and
I've got the statement placed right before the end </script> tag...tell me if you see
a glaring case of needing to move it to a more appropriate space.


<script runat="server">
Function GetUser(ByVal userId As String, ByVal userPassword As String) As System.Data.DataSet
Dim connectionString As String = "server='(local)'; trusted_connection=true; database='VSdatastore'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)

Dim queryString As String = "SELECT [Users].* FROM [Users] WHERE (([Users].[UserId] = @.UserId) AND ([Users].[U"& _
"serPassword] = @.UserPassword))"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_userId As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_userId.ParameterName = "@.UserId"
dbParam_userId.Value = userId
dbParam_userId.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_userId)
Dim dbParam_userPassword As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_userPassword.ParameterName = "@.UserPassword"
dbParam_userPassword.Value = userPassword
dbParam_userPassword.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_userPassword)

Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function
Sub LoginBtn_Click(Sender As Object, E As EventArgs)

If Page.IsValid Then
Dim userDS As New System.Data.DataSet
userDS = GetUser(UserId.Text, UserPassword.Text)
If userDS.Tables(0).Rows.Count = 1 Then
FormsAuthentication.RedirectFromLoginPage(UserId.Text, false)
Else
Msg.Text = "Invalid UserId or Password: Please try again"
End If
End If

End Sub
session("UserId")=UserId
</script


Thx again.
Reid C.|||i think this should work...

If Page.IsValid Then

Dim userDS As New System.Data.DataSet

userDS = GetUser(UserId.Text, UserPassword.Text)

If userDS.Tables(0).Rows.Count = 1 Then
'valid user...
session("UserId")=UserId

FormsAuthentication.RedirectFromLoginPage(UserId.Text, false)

Else

Msg.Text = "Invalid UserId or Password: Please try again"

End If

End If

End Sub

session("UserId")=UserId

|||In your revision you have the "session..." statement right after
the "If userDS.Tables(0).Rows.Count = 1 Then" statement which
made sense as soon as I saw it. But you also have the same
"session..." statement again after the "End Sub" statement. Is
this just a typo on your part from copying and pasting what I
sent you, or does it need to be there?

I am assuming it is a copy&paste oversight...unless you answer
back that it needs to be repeated...

Thx much again for your help.
Reid C.|||See if you can review the code for my datagrid page and see where I'm going wrong.
One thing, the "UserId" I need to compare is in the datatable as "PropUserId" because
I also have a column in the table "VendorUserId" and need to reference both. So I
need to compare the session "UserId" with the table's "PropUserId" column and I've
added a statement in the "Function GetVendorEquipment..." that says the "PropUserId"
column is equivalent to "UserId"...but I am getting a blank table on the page when I
run it.


<script runat="server"
Function GetVendorEquipment() As System.Data.DataSet
Dim connectionString As String = "server='(local)'; trusted_connection=true; database='VSdatastore'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
dim UserId as String
dim PropUserId as String
PropUserId=session("UserId")
Dim queryString As String = "SELECT [VendorEquipment].* FROM [VendorEquipment] WHERE [PropUserId]='" & UserId & "'"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)

Return dataSet
End Function

Sub Page_Load(sender As Object, e As EventArgs)
DataGrid1.DataBind()
End Sub

</script>

Thx again for your help.
Reid C.|||ur userid seems to be a number...
so you have to use


Dim queryString As String = "SELECT [VendorEquipment].* FROM [VendorEquipment] WHERE [PropUserId]=" & PropUserId

also one other suggestion...bind your datagrid within if not ispostback...loop


Sub Page_Load(sender As Object, e As EventArgs)
if not ispostback then
DataGrid1.DataBind()
end if
End Sub

HTH

Query by Time-Slices

Dear NG,
I want to query a table like this:
Customer | Money | Time
A 12 12:01
B 17 12:03
C 25 12:06
D 14 12:09
E 10 12:11
...
My target is to have the SUM of Money Transfers by TIME SLICE, eg.
12:00 - 12:05: 29
12:05 - 12:10: 39
12:10 - 12:15: 10
...
How can I query this?
Thank you very much
RudiI am not sure what format your "Time" column is stored, but perhaps this
will get you started:
SELECT SUM(SomeColumn) AS SomeColumn, 'TheTimeSlice' = CASE WHEN TheTime
BETWEEN '12:00' AND '12:05' THEN '12:00 - 12:05' WHEN TheTime BETWEEN
'12:06' AND '12:10' THEN '12:06 - 12:10' END
FROM YourTable
GROUP BY CASE WHEN TheTime BETWEEN '12:00' AND '12:05' THEN '12:00 - 12:05'
WHEN TheTime BETWEEN '12:06' AND '12:10' THEN '12:06 - 12:10' END
Keith Kratochvil
<rudolf.ball@.asfinag.at> wrote in message
news:1141651834.317186.293110@.i39g2000cwa.googlegroups.com...
> Dear NG,
> I want to query a table like this:
> Customer | Money | Time
> A 12 12:01
> B 17 12:03
> C 25 12:06
> D 14 12:09
> E 10 12:11
> ...
> My target is to have the SUM of Money Transfers by TIME SLICE, eg.
> 12:00 - 12:05: 29
> 12:05 - 12:10: 39
> 12:10 - 12:15: 10
> ...
> How can I query this?
> Thank you very much
> Rudi
>|||Thank you very much,
but if I want to split a DAY into 5-MIN-SLICES, how can I do this:
CASE?
Thank you
Rudi|||Please post table DDLs so that others can understand the datatypes, keys,
constraints etc. What is the datatype of the time column? Also time and
money are reserved words in t-SQL.
Your sample data is not very clear. Do you need rows for all 5 minute slice
irrespective of whether a transfer occured or not? If a transfer occured
exactly on 12:05 ( AM/PM ) , do you want to account for it in the 12:00 -
12:05 group or 12:05 - 12:10 group?
As a general response, for such problems consider integer division on the
expression that returns the number of minutes from the starting point. For
instance, in this case it would be: DATEDIFF( minute, 0, time_ ) / 5. You
can use this expression in your GROUP BY clause to return the resultset you
want.
Anith|||Yes you can, by relying on integer division.
CREATE TABLE Test(Customer char(1),Money int,Time smalldatetime)
INSERT INTO Test VALUES ('A',12,'12:01')
INSERT INTO Test VALUES ('B',17,'12:03')
INSERT INTO Test VALUES ('C',25,'12:06')
INSERT INTO Test VALUES ('D',14,'12:09')
INSERT INTO Test VALUES ('E',10,'12:11')
SELECT CONVERT(char(5),DATEADD(minute,
MIN(DATEDIFF(minute,'12:00',Time)/5), '12:00'),108)
, CONVERT(char(5),DATEADD(minute,
MIN(DATEDIFF(minute,'12:00',Time)/5), '12:05'),108)
, SUM("Money")
FROM Test
GROUP BY DATEDIFF(minute,'12:00',"Time")/5
DROP TABLE Test
I guess you have something to study now :-)
Gert-Jan
rudolf.ball@.asfinag.at wrote:
> Dear NG,
> I want to query a table like this:
> Customer | Money | Time
> A 12 12:01
> B 17 12:03
> C 25 12:06
> D 14 12:09
> E 10 12:11
> ...
> My target is to have the SUM of Money Transfers by TIME SLICE, eg.
> 12:00 - 12:05: 29
> 12:05 - 12:10: 39
> 12:10 - 12:15: 10
> ...
> How can I query this?
> Thank you very much
> Rudi|||With SQL 2005, you could create a mapping from time to some integer domain
(say, convert to minutes in the day and divide by 5), then use the AVG(col)
OVER (PARTITION BY integerslice) functionality that was added. This avoids
having to write all of the slices out in a big case statement.
good luck.
Conor
<rudolf.ball@.asfinag.at> wrote in message
news:1141657033.464616.225810@.j33g2000cwa.googlegroups.com...
> Thank you very much,
> but if I want to split a DAY into 5-MIN-SLICES, how can I do this:
> CASE?
> Thank you
> Rudi
>

query by time

I am trying to query a db by date and time ie I want records from 9/2/2007 to 9/22/2007 (selectable @.startdate and @.enddate) also i want to be able to sort by time ie shift (1st 7:00am to 3:00pm 2nd 3:00 pm to 11:00 pm 3rd 11:00pm to 7:00am) i can query for the date but not sure how to by time. my db data is coming in 9/13/2007 10:35:18 AM

Thanks

Ed

Quote:

Originally Posted by esadler

I am trying to query a db by date and time ie I want records from 9/2/2007 to 9/22/2007 (selectable @.startdate and @.enddate) also i want to be able to sort by time ie shift (1st 7:00am to 3:00pm 2nd 3:00 pm to 11:00 pm 3rd 11:00pm to 7:00am) i can query for the date but not sure how to by time. my db data is coming in 9/13/2007 10:35:18 AM

Thanks

Ed


consider the BETWEEN operator (is it an operator or clause or pharse :D )...

search the online help