|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
query help
Here is a query, I wanted to write optimised query. in the below query I'm executing two times the query "select rid from rtm where tid=3"
How can i re write this query to run only one time. any optimization suggestions are much appriciaated. Here is the query select f.pid,f.yearmonth, rs.rid, p.pnumber,f.fs, r.function from f, ( select rID from RTM where tid=3 ) as rs, p, r where rs.rid = r.rid and f.rid = rs.rid and p.pid = f.pid and f.yearmonth between 200405 and 200504 union select ah.pid, ah.yearmonth, rs.rid, p.pnumber, ah.ahrs,-1 from ( select rID from RTM where tid=3 ) as rs, p, ah where rs.rid = ah.rid and p.pid = ah.pid and ah.yearmonth between 200405 and 200409 order by rs.rid Here rid,pid are primary key in their respective tables |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > query help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|