Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Comparison problem

Author  Topic 

aks
Starting Member

28 Posts

Posted - 2005-03-15 : 12:34:25
Hi,
I have a table with following fields:
UID INT NAME
============================================
34 1111 Jan
34 1124 2004
34 67 hr
34 1117 JULY
34 1124 2004
34 56 hr
56 1111 JAN
56 1125 2005
56 3 hr
56 1119 SEPT
56 1124 2004
56 78 hr

I'm trying to get the output as JAN in 2005(1125) only not 2004(1124)
BUT JULY I want in 2004(1124) LIKE:
UID NAME
============================
34 1117
34 1124
34 56
56 1111
56 1125
56 3
56 1119
56 1124
56 78
I used the foolwing query but its giving me NO JAN value neither 2004 nor 2005.

select a.uid,b.val_int from hr a, hr b,hr c where
a.recordset_id=b.recordset_id and
a.recordset_id=c.recordset_id
AND
((a.val_int=1111and b.val_int=1125) or
(a.val_int=1112 and b.val_int=1125)or
(a.val_int=1113 and b.val_int=1125) or
a.val_int=1114 or
a.val_int=1115 or
a.val_int=1116 or
a.val_int=1117 or
a.val_int=1118 or
a.val_int=1119 or
a.val_int=1120 or
a.val_int=1121 or
a.val_int=1122
)
AND
c.question_id=1123
order by a.uid


aks
Starting Member

28 Posts

Posted - 2005-03-15 : 13:27:09
can sombdy please help me???
Go to Top of Page

aks
Starting Member

28 Posts

Posted - 2005-03-15 : 14:21:58
any help
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-15 : 14:26:36
well i for one have no idea what exactly you really need.
post create table statemnts, sample data in the form of Insert into statements and desired results based on the sample data.
that way we can simply copy/paste the data to our QA and run it and test it.



Go with the flow & have fun! Else fight the flow
Go to Top of Page

aks
Starting Member

28 Posts

Posted - 2005-03-15 : 14:58:16
In simple words
I have columns
UID INT
=========================
2 1111
2 1124
2 6
4 1111
4 1125
4 9
4 1117
4 1124
4 7
5 1111
5 1125
5 7
I want the row with (INT=1111 AND INT=1125) NOT 1124
OUTPUT
========
4 9
4 7
I hope this will help u.
Go to Top of Page

aks
Starting Member

28 Posts

Posted - 2005-03-15 : 14:58:21
In simple words
I have columns
UID INT
=========================
2 1111
2 1124
2 6
4 1111
4 1125
4 9
4 1117
4 1124
4 7
5 1111
5 1125
5 7
I want the row with (INT=1111 AND INT=1125) NOT 1124
OUTPUT
========
4 9
4 7
I hope this will help u.
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-15 : 15:04:23
well i don't want to be a pain but it doesn't help.
because you say you want rows where (INT=1111 AND INT=1125) NOT 1124
but in the results you have INT 9 and 7
and that logic is a bit strange to me.


Go with the flow & have fun! Else fight the flow
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-03-16 : 01:31:11
I didn't understand it either - I thought it was just me!

Kristen
Go to Top of Page
   

- Advertisement -