Showing posts with label supposed. Show all posts
Showing posts with label supposed. Show all posts

Saturday, February 25, 2012

Problem with query

Hi,
I have a query that is supposed to return records and make a left join where
one field is not null, but for some reason is not working properly and
returns the records even though they are null.
SELECT *
FROM cases a
left join activities as w on a.id = w.caseid AND w.Dateinitiated = (Select
MAX(y.Dateinitiated)
From Activities y Where y.caseid = a.id AND y.ActType ='HISTORY' and
y.dateinitiated IS NOT NULL and y.processtep IS NOT NULL)
Any help is greately appreciated.
AleksAleks,
The reason the query seems to be returnning records from Activities,
where the Dateinitiated column is null, is because you have specified an
Outer Join.
When you specify An Outer Join, Al records from the Outer table are
returned, even when there is no match on the other side. You actually are
NOT returning any data from Activities Table where Dateinitiated column is
null. If you look at those rows, you'll probably notice that all the field
s
from Activities table are null there...
"Aleks" wrote:

> Hi,
> I have a query that is supposed to return records and make a left join whe
re
> one field is not null, but for some reason is not working properly and
> returns the records even though they are null.
> --
> SELECT *
> FROM cases a
> left join activities as w on a.id = w.caseid AND w.Dateinitiated = (Select
> MAX(y.Dateinitiated)
> From Activities y Where y.caseid = a.id AND y.ActType ='HISTORY' and
> y.dateinitiated IS NOT NULL and y.processtep IS NOT NULL)
> --
> Any help is greately appreciated.
> Aleks
>
>

Monday, February 20, 2012

problem with ordering by rank

I have a query that is supposed to order the results by rank. When I actually get the results though, it doesn't seem like the rank makes sense. In the result set that I just got, I got 6 records where I did a keyword search on 'sales'. Here's what I got. The word sales was mentioned ...

1. 7 times
2. 2 times
3. 3 times
4. 4 times
5. 3 times
6. 1 time

As a casual user of the system, this ranking wouldn't seem logical to me because I would expect it to have the listings with the most occurances of 'sales' higher in the list. Can someone explain why it works this way and is there a flag or something that I need to set to get it to work more along the lines of what we're expecting? Thanks.

? I assume you're referring to FTS? Unfortunately, there's not a lot you can do to control it. If you want more info about the algorithms it uses for ranking, see: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql90/html/sql2005ftsearch.asp -- Adam MachanicPro SQL Server 2005, available nowhttp://www..apress.com/book/bookDisplay.html?bID=457-- <gswartz@.discussions.microsoft.com> wrote in message news:bf865951-9156-4718-8184-64968a57e0f8@.discussions.microsoft.com... I have a query that is supposed to order the results by rank. When I actually get the results though, it doesn't seem like the rank makes sense. In the result set that I just got, I got 6 records where I did a keyword search on 'sales'. Here's what I got. The word sales was mentioned ... 1. 7 times2. 2 times3. 3 times4. 4 times5. 3 times6. 1 time As a casual user of the system, this ranking wouldn't seem logical to me because I would expect it to have the listings with the most occurances of 'sales' higher in the list. Can someone explain why it works this way and is there a flag or something that I need to set to get it to work more along the lines of what we're expecting? Thanks.