I have three tables
Table1
col1, col2
Table2
col1, col2
table3
col1, col2, col3
col2 of table2 is a foreign key refering tabl1(col1)
col2 of table3 is a foreign key refering table2(col1)
I want to get for each col1 in table1, how many distinct values of col3 are there in table3
I tryed...
you mean
select tbl1.*
from tbl1 inner join tbl2
on tbl1.col2 = tbl2.col1
inner join tbl3
on tbl1.col2 = tbl3.col1
where ((tbl3.col2 is not null) AND (tbl2.col2 is not null))
this code is not giving me the right recordset
col1 col2
1 1
2 1
3 2
4 3
the query...
Hi,
I have three table
say
tbl1
col1 col2
1 1
2 1
3 2
4 3
tbl2
col1 col2
1 aa
2 bb
tbl3
col1 col2
1 dd
2 ee
3 ff
col2 of tbl1 is a foreign key refering to col2 of both tbl2 and tbl3
I want to...
it is returnig more records
there ia a duplicate value on sve.sve_stu_id, sso.sso_stu_id, ses.SES_SVE_ID, eae.EAE_SES_ID
what should my could look like in ansi-standard join statement
I was trying to convert this query to ansi standard join statemet, but it is not giving the same record set waht did I miss
<html>
<head>
<title>query that should be converted</title>
</head>
<body>
SELECT eae.EAE_SES_ID
FROM PHOENIX.EXPEDITED_ADVERSE_EVENTS EAE
WHERE...
I have a query and, no matter how many indexes I have added I can't remove the clustered index scanning
what do you suggest
below is the show plan text
|--Filter(WHERE:(((((((([@p_In_EVT_LAST_CHANGED_USER_ID_Num]=NULL OR...
Thank you for ur swift response
Actually the query is like this.There is an incoming parameter @p_In_EAE_NUMBER_Vch
SELECT EAE_ID FROM EXPEDITED_ADVERSE_EVENTS
WHERE CAST(EAE_NUMBER AS VARCHAR(15)) LIKE ISNULL(@p_In_EAE_NUMBER_Vch, CAST(EAE_NUMBER AS VARCHAR(15)) )
any suggestion
I have this query
The table PHOENIX.EXPEDITED_ADVERSE_EVENTS has clustsed index defined on EAE_ID and nonclustsred index defined on EAE_NUMBER
SELECT EAE_ID FROM PHOENIX.EXPEDITED_ADVERSE_EVENTS
WHERE CAST(EAE_NUMBER AS VARCHAR(15)) LIKE ISNULL(NULL, CAST(EAE_NUMBER AS VARCHAR(15)) )
when I...
to make the que easy
I have a table over 14 columns
a clustsred index is defined on the PK.
I am wrting a query to select 10 of the xolumns from the table, which leads to a clustsred index scan( that makes my query very slow)
I want to optimize the query by adding some indexes.
do I have to add...
what is a substitute for covering index in sql server 2000
There are many columns which are causing clustsred index scan that degrades my query performance
here is part of the showplan in my query
|--Clustered Index Scan(OBJECT:([DaidsesDev4].[Phoenix].[EAE_DIAGNOSTICS].[EDI_ID_PK])...
---code
SELECT 'Study Agent' AS StudyProductType,
esp.ESP_PRODUCT_NAME AS StudyIntervention,
esp.ESP_RELATIONSHIP_TYPE AS RelationshipToPrimaryAE,
esp.ESP_EXPECTED_TYPE AS StudyProductExpectedness
FROM phoenix.EAE_STUDY_PRODUCTS esp INNER JOIN phoenix.EAE_STUDY_AGENTS esa
ON esa.ESA_ESP_ID...
I have created a nonclustsred index on a column of a table that is refered in on stataement of a inner join statement;
but it is still going clustsred index scan,
what is the reason behind this and how can I solve this
Thanks
I have a table say
tbl
col1 col2
1 A
2 B
3 C
Null F
5 G
Null H
Here is what I want a parameter is passed to my stored proc
@col1 int = Null
I want to select a value from tbl1 according to @col1
if @col1 is null I will select all the records of tbl...
I have a local variable say @var
I want to select some data from a table XY based on the values of these local variable. The values for the local variable can be NULL or have data
Here is what I want, I want to write a single query to select data from the table only if the variable is not null...
Given this table
col1 col2
1 yes
1 no
2 yes
2 yes
3 no
3 no
4 yes
4 no
I want to query out that for each value in col1 if its corresponding value in col2 is yes, yes - it will be yes,
no, yes - it will be yes, no, no it will...
Thank you very much I appreciate that
now I want to write a query that for each record in the parent tables I want to get the corresponding record in the child table in a single column
eg id 1 has in parent table has three corresponding record in child table my output should look like
id...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.