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
 General SQL Server Forums
 New to SQL Server Programming
 ORA-00907: missing right parenthesis

Author  Topic 

ana_jj
Starting Member

6 Posts

Posted - 2012-05-30 : 12:22:40
What the hell am I missing?? Please help me!


select pr.opis, pr.cena
from parchinja_obleka pr, proizvoditeli p, rezervacii r, klienti k
where
pr.prid=p.prid and
r.prid=pr.prid and
k.klid=r.klid
group by pr.opis, pr.cena having count(k.klid)=(select max(maksimum) from
(select count(r.klid) as maksimum from rezervacii r,parchinja_obleka pr, proizvoditeli p, klienti k
where pr.prid=p.prid and
r.prid=pr.prid and
k.klid=r.klid and
r.kupeno='N'
group by pr.opis, pr.cena having k.klid=(select k.klid
from rezervacii r, trgovski_centri t, butici b, parchinja_obleka pr, klienti k
where r.oblid=pr.oblid and
r.prid=pr.prid and
k.klid=r.klid and
r.kupeno='N'
order by pr.opis, pr.cena having count(r.oblid)>1
)))

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-05-30 : 12:35:43
You're probably missing sql server?
reformatting helps.

Looks ok - are you sure that's what you are executing?
Try executing parts of it starting at the inner queries and working outwards until you find the issue.

I suspect it might be the subquery in the second having clause as that dodesn't really make sense.
The having should test an agregate and you have multiple rows returned from a subquery.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

ana_jj
Starting Member

6 Posts

Posted - 2012-05-30 : 12:38:56
select pr.opis, pr.cena
from parchinja_obleka pr, proizvoditeli p, rezervacii r, klienti k
where
pr.prid=p.prid and
r.prid=pr.prid and
k.klid=r.klid
group by pr.opis, pr.cena having count(k.klid)=(select max(maksimum) from
(select count(r.klid) maksimum from rezervacii r,parchinja_obleka pr, proizvoditeli p, klienti k
where pr.prid=p.prid and
r.prid=pr.prid and
k.klid=r.klid and
r.kupeno='N'
group by pr.opis,pr.cena))


This works completly ok, but I need the option for getting those information's where the reservation for the pieces of clothes is more than one. :/
Go to Top of Page

ana_jj
Starting Member

6 Posts

Posted - 2012-05-30 : 12:44:20
Where can I add this option ?
count(r.oblid)>1
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-05-30 : 12:51:20
ana_jj, you are using Oracle, and SQLTeam.com is for Microsoft SQL Server. You'll get better help on an Oracle forum. Although the syntax is similar between the two, there's enough of a difference that it's hard for us to help.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

ana_jj
Starting Member

6 Posts

Posted - 2012-05-30 : 12:54:17
Ok Tara, but maybe somebody knows how to handle with my problem :/
Go to Top of Page

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2012-05-30 : 12:56:46
You are wasting time, In my limited experince, you cannot assume that syntax which works in SQL Server will work in Oracle. Even if the sp compiles there with no warnings.
It is way different.
If I were you I would post your oracle question in oracle.com where they have forums or in stackoverflow.com.

You can continue to be stubborn but it's self defeating.

quote:
Originally posted by ana_jj

Ok Tara, but maybe somebody knows how to handle with my problem :/

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-05-30 : 13:15:32
Wish there was a "like" option for Adam's post.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-05-30 : 13:27:18
Sounds like a requirements issue (and I'm not sure what you mean).

Do you understand what was wrong with the previous version.
The having clause is for checking a value for a group - i.e. an aggregate (usually)
You were trying to check each row of a group - yoou could do that in the where clause maybe - perhaps setting an integer value which yoou can sum to get a group value.

Don't mind trying to help our disadvantaged brothers. They need our sympathy :).

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -