Showing posts with label value. Show all posts
Showing posts with label value. Show all posts

Friday, March 30, 2012

Help In Coding

Dim objConn As New SqlConnection
Dim objCmd As New SqlCommand
Dim Value As String = EventCmb.SelectedItem.ToString()
objConn.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename='C:\Documents and Settings\HP\My Documents\Visual Studio 2005\WebSites\FYP2\App_Data\Event.mdf';Integrated Security=True;Connect Timeout=30;User Instance=True"
Try
objConn.Open()
objCmd.Connection = objConn
objCmd.CommandType = CommandType.Text
objCmd.CommandText = "SELECT EventTel FROM Event WHERE (EventID = @.Value)" ' See how i changed Value to @.Value. This is called a Named Parameter
objCmd.Parameters.AddWithValue("@.Value", Value) ' Add the @.value withthe actual value that should be put. This makes it securer
Dim RetVal As Object = objCmd.ExecuteScalar() ' This returns the First Column of the first row regardless of how much data is returned.
If Not ((RetVal Is Nothing) Or (RetVal Is DBNull.Value)) Then
ContactLbl.Text = RetVal.ToString()
Else
' noting was returned
End If
Catch ex As Exception
Throw ex
Finally
objConn.Close()
End Try

There's an error for in line "Dim RetVal As Object = objCmd.ExecuteScalar() "

Error Message is as follow"Conversion failed when converting the nvarchar value 'LTA' to data type int."

It is due to "ExecuteScalar() "can only store int? I just need to display one data, andValue data comes form a combo box "EventCmb", which i wanted to find the selected String, compared to the "Event" database to get the "EventTel" data How do i solved this problem, any advice? Thanks!

In your code

Dim Value As String = EventCmb.SelectedItem.ToString()

you defined Value as a string, but in our sql

"SELECT EventTel FROM Event WHERE (EventID = @.Value)"

EventID look like a int, this is where the convering error come from

Hope this help

sql

Friday, March 23, 2012

Help creating a DELETE trigger.

I need to create a trigger that will run whenever a record is deleted. I
want the trigger to delete records from table2 where the value in the ID
field matches the value in the ID field of the record being deleted from
table1.
I'm new to triggers and am not sure how to set this up.
Thanks,
JohnTry,
create trigger tr_table1_del on table1
for delete
as
set nocount on
if exists(select * from deleted as d inner join table2 as t on d.[id] = t[id])
begin
delete table2
where exists(select * from deleted ad d where d.[id] = table2.[id])
if @.@.error != 0
begin
rollback transaction
raiserror('Error deleting rows in table2.', 16, 1)
return
end
end
go
AMB
"John Piotrowski" wrote:

> I need to create a trigger that will run whenever a record is deleted. I
> want the trigger to delete records from table2 where the value in the ID
> field matches the value in the ID field of the record being deleted from
> table1.
> I'm new to triggers and am not sure how to set this up.
> Thanks,
>
> John

Wednesday, March 21, 2012

Help adding fields to a table

I have a list of values in one field in a table, and I want to modify another
table that I have to add a new field for each value in the other field. In
case this doesn't make sense, I've posted examples below -
Table 1
Field 1
values - Apple, Pear, Banana, Orange
Table 2
I want to create four fields, one for each of the values in field 1 of table 1
I thought about doing this as a loop, but the only way I see to create a
field is using alter table, and that only allows me to enter a text name for
the field, instead of calling another field or value from another field.
Any ideas on how to do this? If it matters, I'm using SQL Query Analyzer
v.8.0.
Thanks,
Dan
You can use something like this ..
DECLARE @.SQL varchar(8000)
SET @.SQL = 'SELECT * FROM SYSDATABASES'
EXEC (@.SQL)
Create a dynamic query and execute it using EXEC.
Thanks!
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCTS: SQL Server 2005
"Dan" wrote:

> I have a list of values in one field in a table, and I want to modify another
> table that I have to add a new field for each value in the other field. In
> case this doesn't make sense, I've posted examples below -
> Table 1
> Field 1
> values - Apple, Pear, Banana, Orange
> Table 2
> I want to create four fields, one for each of the values in field 1 of table 1
>
> I thought about doing this as a loop, but the only way I see to create a
> field is using alter table, and that only allows me to enter a text name for
> the field, instead of calling another field or value from another field.
> Any ideas on how to do this? If it matters, I'm using SQL Query Analyzer
> v.8.0.
>
> Thanks,
> Dan
>

Wednesday, March 7, 2012

Help - Query with index problem

Hi all
I have a table which have four index. I found that some vales i can run the query which hit the index and some value cannot. The details as follows
Table : mytabl
Index : my_index_4 ( company_code + order_type + order_date
Query 1: select * from mytable where company_code='100' and order_type='ABC' and
order_date between '2003-01-01' and '2003-12-31
Query 2: select * from mytable where company_code='100' and order_type='ABC' and
order_date between '2002-01-01' and '2002-12-31
Query 3: select * from mytable (index=my_index_4) where company_code='100' and order_type='ABC' and
order_date between '2002-01-01' and '2002-12-31
Query 1 & 3 only need 1 second to return the result set. But Query 2 need more than 20 second to run. I check it and found that the Query will not hit the index. It will use table scan.
Can you tell me why (I tried to re-built the index, update statistic) ? How can I fix it without using the "index="
Regards
SimoDo you have an index on order_date? Clustered or non-clustered? How many
rows does query 1 vs. 2 return? Out of how many in the table? How many pages
does the table use?
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Simon" <anonymous@.discussions.microsoft.com> wrote in message
news:EC349819-01AD-4A88-87A1-48B4FA4836DE@.microsoft.com...
> Hi all,
> I have a table which have four index. I found that some vales i can run
the query which hit the index and some value cannot. The details as
follows.
> Table : mytable
> Index : my_index_4 ( company_code + order_type + order_date)
> Query 1: select * from mytable where company_code='100' and
order_type='ABC' and
> order_date between '2003-01-01' and '2003-12-31'
> Query 2: select * from mytable where company_code='100' and
order_type='ABC' and
> order_date between '2002-01-01' and '2002-12-31'
> Query 3: select * from mytable (index=my_index_4) where
company_code='100' and order_type='ABC' and
> order_date between '2002-01-01' and '2002-12-31'
> Query 1 & 3 only need 1 second to return the result set. But Query 2 need
more than 20 second to run. I check it and found that the Query will not
hit the index. It will use table scan.
> Can you tell me why (I tried to re-built the index, update statistic) ?
How can I fix it without using the "index=".
> Regards,
> Simon
>|||Hi Simon
The only base not covered in your solutions is statistics
distribution - SQL Server is deciding that for last year's
data, a table scan is better, but for this year's the
index would be more efficient.
The UPDATE STATISTICS options you used are not specified
but you may want to start with
UPDATE STATISTICS ... WITH FULLSCAN, INDEX and work
downwards from there.
If the Optimizer then chooses correctly, you might want to
reduce to a 50% scan, then reduce to 25% or increase to
75% depending on the 50% result.
Brian
>--Original Message--
>Hi all,
>I have a table which have four index. I found that some
vales i can run the query which hit the index and some
value cannot. The details as follows.
>Table : mytable
>Index : my_index_4 ( company_code + order_type +
order_date)
>Query 1: select * from mytable where company_code='100'
and order_type='ABC' and
> order_date between '2003-01-01' and '2003-
12-31'
>Query 2: select * from mytable where company_code='100'
and order_type='ABC' and
> order_date between '2002-01-01' and '2002-
12-31'
>Query 3: select * from mytable (index=my_index_4) where
company_code='100' and order_type='ABC' and
> order_date between '2002-01-01' and '2002-
12-31'
>Query 1 & 3 only need 1 second to return the result set.
But Query 2 need more than 20 second to run. I check it
and found that the Query will not hit the index. It will
use table scan.
>Can you tell me why (I tried to re-built the index,
update statistic) ? How can I fix it without using
the "index=".
>Regards,
>Simon
>
>.
>|||I tried to run "UPDATE STATISTICS mytable WITH FULLSCAN, INDEX "
It give the same result.
-- Brian Katz wrote: --
Hi Simon
The only base not covered in your solutions is statistics
distribution - SQL Server is deciding that for last year's
data, a table scan is better, but for this year's the
index would be more efficient.
The UPDATE STATISTICS options you used are not specified
but you may want to start with
UPDATE STATISTICS ... WITH FULLSCAN, INDEX and work
downwards from there.
If the Optimizer then chooses correctly, you might want to
reduce to a 50% scan, then reduce to 25% or increase to
75% depending on the 50% result.
Brian
>--Original Message--
>Hi all,
>>I have a table which have four index. I found that some
vales i can run the query which hit the index and some
value cannot. The details as follows.
>>Table : mytable
>Index : my_index_4 ( company_code + order_type +
order_date)
>>Query 1: select * from mytable where company_code='100'
and order_type='ABC' and
> order_date between '2003-01-01' and '2003-
12-31'
>>Query 2: select * from mytable where company_code='100'
and order_type='ABC' and
> order_date between '2002-01-01' and '2002-
12-31'
>>Query 3: select * from mytable (index=my_index_4) where
company_code='100' and order_type='ABC' and
> order_date between '2002-01-01' and '2002-
12-31'
>>Query 1 & 3 only need 1 second to return the result set.
But Query 2 need more than 20 second to run. I check it
and found that the Query will not hit the index. It will
use table scan.
>>Can you tell me why (I tried to re-built the index,
update statistic) ? How can I fix it without using
the "index=".
>>Regards,
>Simon
>>.
>|||The table around 900,000 records. The query 1 and query 2 return about 5000 records.
All index are non-clustered index. Other than my_index_4, there are two other index with the filed "order_date".
Index : my_index_4 ( company_code + order_type + order_date)
Index : my_index_3 ( company_code + order_no + order_date)
Index : my_index_2 ( company_code + cutomer_no + order_date)
-- Tibor Karaszi wrote: --
Do you have an index on order_date? Clustered or non-clustered? How many
rows does query 1 vs. 2 return? Out of how many in the table? How many pages
does the table use?
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"Simon" <anonymous@.discussions.microsoft.com> wrote in message
news:EC349819-01AD-4A88-87A1-48B4FA4836DE@.microsoft.com...
> Hi all,
>> I have a table which have four index. I found that some vales i can run
the query which hit the index and some value cannot. The details as
follows.
>> Table : mytable
> Index : my_index_4 ( company_code + order_type + order_date)
>> Query 1: select * from mytable where company_code='100' and
order_type='ABC' and
> order_date between '2003-01-01' and '2003-12-31'
>> Query 2: select * from mytable where company_code='100' and
order_type='ABC' and
> order_date between '2002-01-01' and '2002-12-31'
>> Query 3: select * from mytable (index=my_index_4) where
company_code='100' and order_type='ABC' and
> order_date between '2002-01-01' and '2002-12-31'
>> Query 1 & 3 only need 1 second to return the result set. But Query 2 need
more than 20 second to run. I check it and found that the Query will not
hit the index. It will use table scan.
>> Can you tell me why (I tried to re-built the index, update statistic) ?
How can I fix it without using the "index=".
>> Regards,
> Simon
>>|||Seems like SQL Server estimates one query to return more rows than the other query. The query plan
should tell you this information. Since you do SELECT *, you effectively eliminate the option for
SQL Server to use a covering index. Do you really need all columns?
Since you don't have a clustered index and SQL Server cannot cover the query, SQL Server has to
visit one page for each row to return. I.e., SQL Server has to visit 5000 pages.
Creating a clustered index on order_date will probably make the query very fast...
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"simon" <anonymous@.discussions.microsoft.com> wrote in message
news:9FCD7B02-8132-4D9A-B13C-B39BC3E7432C@.microsoft.com...
> The table around 900,000 records. The query 1 and query 2 return about 5000 records.
> All index are non-clustered index. Other than my_index_4, there are two other index with the
filed "order_date".
> Index : my_index_4 ( company_code + order_type + order_date)
> Index : my_index_3 ( company_code + order_no + order_date)
> Index : my_index_2 ( company_code + cutomer_no + order_date)
>
> -- Tibor Karaszi wrote: --
> Do you have an index on order_date? Clustered or non-clustered? How many
> rows does query 1 vs. 2 return? Out of how many in the table? How many pages
> does the table use?
> --
> Tibor Karaszi, SQL Server MVP
> Archive at:
> http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
>
> "Simon" <anonymous@.discussions.microsoft.com> wrote in message
> news:EC349819-01AD-4A88-87A1-48B4FA4836DE@.microsoft.com...
> > Hi all,
> >> I have a table which have four index. I found that some vales i can run
> the query which hit the index and some value cannot. The details as
> follows.
> >> Table : mytable
> > Index : my_index_4 ( company_code + order_type + order_date)
> >> Query 1: select * from mytable where company_code='100' and
> order_type='ABC' and
> > order_date between '2003-01-01' and '2003-12-31'
> >> Query 2: select * from mytable where company_code='100' and
> order_type='ABC' and
> > order_date between '2002-01-01' and '2002-12-31'
> >> Query 3: select * from mytable (index=my_index_4) where
> company_code='100' and order_type='ABC' and
> > order_date between '2002-01-01' and '2002-12-31'
> >> Query 1 & 3 only need 1 second to return the result set. But Query 2 need
> more than 20 second to run. I check it and found that the Query will not
> hit the index. It will use table scan.
> >> Can you tell me why (I tried to re-built the index, update statistic) ?
> How can I fix it without using the "index=".
> >> Regards,
> > Simon
> >>

Help - Problem with an Expresion

I have Created an expression
= Fields!Net_revenue.Value/ Fields!Gross_Revenue.Value
Works fine but Net_Revenue.value is created from Sales Volume * Purchase
Price and if no Sales Volume then the default will be zero.
If the formula tries to divide by a zero I get an -infinity error on the
report.
Tried = IF Fields!Sale_Volume.Value = 0 then 0 ELSE
Fields!Net_revenue.Value/ Fields!Gross_Revenue.Value END IF
but I must be doing something wrong as it returns an error, anyone have any
ideas?Hi Kevin,
Try
= IIF(Fields!Sale_Volume.Value = 0, 0, Fields!Net_revenue.Value/
Fields!Gross_Revenue.Value)
--
Rodney Landrum
Author, "Pro SQL Server Reporting Services" (Apress)
http://www.apress.com
"Kevin" <Kevin@.discussions.microsoft.com> wrote in message
news:7899967B-6164-4272-8D12-4421AC8E05F0@.microsoft.com...
>I have Created an expression
> = Fields!Net_revenue.Value/ Fields!Gross_Revenue.Value
> Works fine but Net_Revenue.value is created from Sales Volume * Purchase
> Price and if no Sales Volume then the default will be zero.
> If the formula tries to divide by a zero I get an -infinity error on the
> report.
> Tried = IF Fields!Sale_Volume.Value = 0 then 0 ELSE
> Fields!Net_revenue.Value/ Fields!Gross_Revenue.Value END IF
> but I must be doing something wrong as it returns an error, anyone have
> any
> ideas?|||Thanks Rodney, that works.
Nearly got it right :)
"Rodney Landrum" wrote:
> Hi Kevin,
> Try
> = IIF(Fields!Sale_Volume.Value = 0, 0, Fields!Net_revenue.Value/
> Fields!Gross_Revenue.Value)
> --
> Rodney Landrum
> Author, "Pro SQL Server Reporting Services" (Apress)
> http://www.apress.com
> "Kevin" <Kevin@.discussions.microsoft.com> wrote in message
> news:7899967B-6164-4272-8D12-4421AC8E05F0@.microsoft.com...
> >I have Created an expression
> >
> > = Fields!Net_revenue.Value/ Fields!Gross_Revenue.Value
> >
> > Works fine but Net_Revenue.value is created from Sales Volume * Purchase
> > Price and if no Sales Volume then the default will be zero.
> >
> > If the formula tries to divide by a zero I get an -infinity error on the
> > report.
> >
> > Tried = IF Fields!Sale_Volume.Value = 0 then 0 ELSE
> > Fields!Net_revenue.Value/ Fields!Gross_Revenue.Value END IF
> >
> > but I must be doing something wrong as it returns an error, anyone have
> > any
> > ideas?
>
>

Monday, February 27, 2012

Help - How to validate parameters?

I need to validate a parameters Length to make sure it is 8 characters long
and whether it is of numeric value and if it is not to display a validation
error message. Is this possible. I'm using reporting service and SQL Server
2000.
Any help will greatly appreciated.Have you tried placing custom code to validate these, then placing a dummy
textbox at the top of the report to call the validate code?
Eg. =Code.ValidateParameters()
Get this to show a box or something if it fails.
"Ken" <Ken@.discussions.microsoft.com> wrote in message
news:D2458D65-E2C3-4C80-951E-D44B389929AA@.microsoft.com...
>I need to validate a parameters Length to make sure it is 8 characters long
> and whether it is of numeric value and if it is not to display a
> validation
> error message. Is this possible. I'm using reporting service and SQL
> Server
> 2000.
> Any help will greatly appreciated.|||Hi, Craig,
my code looks like this:
declare @.lastmonth char(7)
@.lastmonth = code.mycode() <-- will return '2006.02'
select comments from theTable
where yearmonth = @.lastmonth
I execute it and get an error "syntax error near @.lastmonth"
the program of mycode() is in layout, report, report properties, code.
Thanks!
Henry
"Ken" wrote:
> I need to validate a parameters Length to make sure it is 8 characters long
> and whether it is of numeric value and if it is not to display a validation
> error message. Is this possible. I'm using reporting service and SQL Server
> 2000.
> Any help will greatly appreciated.|||Well for starters you can't put multiple lines in the dataset. If you were
doing this you can only do:
="select comments from theTable where yearmonth = "& Code.mycode()
Which will return the SQL statement with the date included.
I thought the original question though was how to validate the parameters?
I was thinking of putting a Testbox on the form which has a value of
=Code.ValidateParameter(Parameters!DateParam.Value)
as an example. Then you can make this visible if the text box has anything
in it.
You can use the same syntax for the SQL statement if you wanted to check the
parameter before you passed it in to the database within the dataset.
Craig
"Henry Chen" <HenryChen@.discussions.microsoft.com> wrote in message
news:7F512BB0-8D5C-4E16-B1E2-6A0270BB0117@.microsoft.com...
> Hi, Craig,
> my code looks like this:
> declare @.lastmonth char(7)
> @.lastmonth = code.mycode() <-- will return '2006.02'
> select comments from theTable
> where yearmonth = @.lastmonth
> I execute it and get an error "syntax error near @.lastmonth"
> the program of mycode() is in layout, report, report properties, code.
> Thanks!
> Henry
>
> "Ken" wrote:
>> I need to validate a parameters Length to make sure it is 8 characters
>> long
>> and whether it is of numeric value and if it is not to display a
>> validation
>> error message. Is this possible. I'm using reporting service and SQL
>> Server
>> 2000.
>> Any help will greatly appreciated.

Help - Can Execute return a value?

Hello
I'm relatively new to SQL Server/T-SQL and find myself stuck with this
problem:
I need to do something like this:
Declare @.someValue NVarchar(100)
Declare @.someFunction Varchar(100)
--
-- Assign value to @.someValue from a Cursor
--
--
-- Assign name of the function to @.someFunction from a Cursor
--
Declare @.ret NVarchar(100)
Execute 'Select @.ret = ' + @.someFunc + '(''' + @.someValue + ''')'
I expect the last Execute statement to leave the return value from the
function in @.ret.
What I get is
Must declare the variable '@.ret'.
I have also tried
Execute sp_ExecuteSQL 'Select @.ret = ' + @.someFunc + '(''' +
@.someValue + ''')'
with the same result.
Any help with making this work or other ways of doing this will be very
much appreciated!
TIA.
Vamsi.Vamsi,
Use sp_executesql.
Declare @.ret NVarchar(100)
declare @.sql nvarchar(4000)
set @.sql = N'Select @.ret = ' + @.someFunc + '(''' + @.someValue + ''')'
exec sp_executesql @.sql, N'@.ret NVarchar(100) output', @.ret output
print @.ret
go
The Curse and Blessings of Dynamic SQL
http://www.sommarskog.se/dynamic_sql.html
AMB|||Splendid!!
I still can't understand that one line of code, but, it worked
perfectly :-)
Thanks very much, AMB.
V.|||tvamsidhar (tvamsidhar@.gmail.com) writes:
> Splendid!!
> I still can't understand that one line of code, but, it worked
> perfectly :-)
For more details on sp_executesql and dynamic SQL in general, see
an article on my web site: http://www.sommarskog.se/dynamic_sql.html.
By the way, if you are new to T-SQL, dynamic SQL is probably not where
you should start.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Thanks Erland, I'll study the article! Its already in my Google
bookmarks :)
As for starting with dynamic SQL, I really don't have a choice :-) I
need to be able to run validations and formatting on type-less text
data that should be "interpreted" to be of datatypes defined in a
metadata repository (SQL Server tables) and satisfying validations
(reg. expressions, TSQL functions/SPs, etc) specified in the same
repository.
Running these on the app. server turned out to be way too inefficient
and cumbursome; hence the dynamic SQL. And although I'm more
experienced with PL/SQL, the powers that be insist on using SQL Server
I thank you for the input.
V.

Sunday, February 19, 2012

help

hi

i have table with folowing columns (subid,itemid)

i want to write select stmt to get subid where itemid =all group of value('1','2')

like this

Select subid from subscriptionItem where itemId in all('1','2')

but this stmt not work

help me

Somthing like this ?

Select SubID From SubscriptionItem Where ItemID in ('1','2')|||

Hi,

If you mean you want those SubID that have both ItemID 1 and 2, then the above will not work.

what you should is..

Select SubID From subscriptionItem Where ItemID in (1,2) group by SubID Having count(0) =2

Assuming that the combination SubID and ItemID is primary (unique).

If they are not unique, which I doubt, then try:

Select SubID FROM (Select distinct SubID, ItemID from SubscriptionItem where ItemID in (1,2)) si Group by SubID having count(0) = 2

Hope this helps

Hello? Left Join?

Am I missing something? I thought LEFT JOIN made the first table return a value even if there was nothing in the second table. Yet this query:

SELECT b.name, isnull(c.call_no, 0)

FROM business b

LEFT JOIN call c ON b.business_id=c.service_business_id

WHERE b.business_id = 1000634

AND c.create_time BETWEEN @.startDate AND @.endDate

Is not returning any rows at all because there are no calls during the time period I'm using.

The query works if I extend the date range to include at least one call, so I know the business id and everything is correct...

Am I losing my mind? Or have I completely misunderstood what LEFT JOIN is supposed to do?

Hi Telos

You need to re-arrange your query slightly, see below.

Chris

SELECT b.name, isnull(c.call_no, 0)

FROM business b

LEFT JOIN call c ON b.business_id=c.service_business_id AND c.create_time BETWEEN @.startDate AND @.endDate

WHERE b.business_id = 1000634

|||

Ok, that works.

I don't understand why though... can I get an explanation?

|||

The reason it didn't work before is that in case of OUTER JOINS the WHERE clause is applied after the ON clause. If you have rows that doesn't satisfy the condition in the ON clause the column values will be NULL and the BETWEEN check will fail (or evaluate to unknown and hence the row(s) will not qualify).

But the way to write the query is to use a simple sub-query in the SELECT list. There is really no reason to use outer join. You need to use outer join construct if you are retrieving more columns from the outer joined table for example. Otherwise, a sub-select is the way to go.

SELECT b.name

, coalesce((select c.call_no

from call c

where b.business_id=c.service_business_id

and c.create_time BETWEEN @.startDate AND @.endDate), 0) as call_no

FROM business b

WHERE b.business_id = 1000634

|||

Ok, that makes sense.

The real query is a bit more complex though, so I was trying to avoid the subselect. The one Chris posted is working well.

Thanks for your help!

|||

The other responses are great. I just thought I would add that in your original query you could have put

AND ((c.create_time BETWEEN @.startDate AND @.endDate)

OR (c.create_time IS NULL)

)

That way your WHERE clause accommodates the fact that the OUTER JOIN may not return a value for c.create_time.

|||

The subtle difference between DanR1's approach and the others is that if the value stored in the table in the c.create_time column is NULL then the row will qualify and, therefore, will be returned. However if the c.create_time column is not nullable then this query will behave in the same way as the others.

Chris

|||

Chris,

Thanks for the elaboration.

Dan