Wednesday, March 28, 2012

Is this query possible in Sql Server ?

I use this query in Oracle, is such query possible in Sql Server, if so,
what is the sql server syntax.
Select * from Contract
where (cn,rev) in
(select cn,rev from Invoice)
Best Regards,
Luqmanthe possibility to use the query in SQL server is
Select * from Contract
where cn in (select cn from Invoice),rev) and rev in (select rev from
Invoice)
"Luqman" <pearlsoft@.cyber.net.pk> wrote in message
news:OLC$eypCFHA.1292@.TK2MSFTNGP10.phx.gbl...
> I use this query in Oracle, is such query possible in Sql Server, if so,
> what is the sql server syntax.
> Select * from Contract
> where (cn,rev) in
> (select cn,rev from Invoice)
> Best Regards,
> Luqman
>
>
>|||the query is
Select * from Contract
where cn in (select cn from Invoice) and rev in (select rev from Invoice)
"Devinder Singh" <devinder79@.hotmail.com> wrote in message
news:eddin1pCFHA.2540@.TK2MSFTNGP09.phx.gbl...
> the possibility to use the query in SQL server is
> Select * from Contract
> where cn in (select cn from Invoice),rev) and rev in (select rev from
> Invoice)
>
> "Luqman" <pearlsoft@.cyber.net.pk> wrote in message
> news:OLC$eypCFHA.1292@.TK2MSFTNGP10.phx.gbl...
>|||the query is
Select * from Contract where cn in (select cn from Invoice) and rev in
(select rev from Invoice)|||Select * from Contract C
where EXISTS
(select 1 from Invoice I
WHERE I.cn = C.Cn AND I.rev = C.rev)
Roji. P. Thomas
Net Asset Management
https://www.netassetmanagement.com
"Luqman" <pearlsoft@.cyber.net.pk> wrote in message
news:OLC$eypCFHA.1292@.TK2MSFTNGP10.phx.gbl...
>I use this query in Oracle, is such query possible in Sql Server, if so,
> what is the sql server syntax.
> Select * from Contract
> where (cn,rev) in
> (select cn,rev from Invoice)
> Best Regards,
> Luqman
>
>
>|||a simple inner join would probably do here.
dean
"Luqman" <pearlsoft@.cyber.net.pk> wrote in message
news:OLC$eypCFHA.1292@.TK2MSFTNGP10.phx.gbl...
> I use this query in Oracle, is such query possible in Sql Server, if so,
> what is the sql server syntax.
> Select * from Contract
> where (cn,rev) in
> (select cn,rev from Invoice)
> Best Regards,
> Luqman
>
>
>|||On Fri, 4 Feb 2005 15:15:49 +0530, Devinder Singh wrote:

>the query is
>
>Select * from Contract where cn in (select cn from Invoice) and rev in
>(select rev from Invoice)
Hi Devinder,
This won't produce the same results as the original query posted by
Luqman. Luqman wants to know if there is one row in Invoice with matching
cn and rev values - you are testing if there is a row with matching cn and
a row (not necessarily the same) with matching rev.
Roji's solution is correct.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||On Fri, 4 Feb 2005 11:04:03 +0100, Dean wrote:

>a simple inner join would probably do here.
Hi Dean,
Only if the combination of cn + rev is unique in the Invoice table. If it
isn't, you'll get duplicates and you'll have to use a derived table
(SELECT DISTINCT cn, rev FROM Invoice) AS D in your join.
I suggest using Roji's solution, which will work regardless of duplicates
in Invoice, without the need for an expensive DISTINCT operator.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||I checked out and I confirm Roji's query meets my requirement.
Thanks to all of you.
Best Regards,
Luqman
"Hugo Kornelis" <hugo@.pe_NO_rFact.in_SPAM_fo> wrote in message
news:lhq601hjmukcmbtbedkh8euf6q337ijva3@.
4ax.com...
> On Fri, 4 Feb 2005 11:04:03 +0100, Dean wrote:
>
> Hi Dean,
> Only if the combination of cn + rev is unique in the Invoice table. If it
> isn't, you'll get duplicates and you'll have to use a derived table
> (SELECT DISTINCT cn, rev FROM Invoice) AS D in your join.
> I suggest using Roji's solution, which will work regardless of duplicates
> in Invoice, without the need for an expensive DISTINCT operator.
> Best, Hugo
> --
> (Remove _NO_ and _SPAM_ to get my e-mail address)sql

No comments:

Post a Comment