Re: Messed Up Query



On Apr 28, 7:51 pm, Mtek <m...@xxxxxxxxxxx> wrote:
Hi,

I have this query:

SELECT q10.q10_count,
vi.mgr_flag,vi.inst_type,vi.inst_num,vi.inst_cst,vi.inst_zip,vi.inst_phone,vi.url,vi.turnover,vi.hold_cnt,
vi.date_,vi.inst_size,vi.inst_dchg,

vh.ticker,vh.q0_shares,vh.q1_shares,vh.q0q1_grwth,vh.q0q1_dchg,vh.shares_out,
mt.comp_name, sd.sector_name, p.closing
FROM vinst vi, vhold vh, master_table mt, stock_data sd, prices p,
(SELECT count(*) q10_count FROM vhold vh
WHERE q1_shares = 0 GROUP BY vh.ticker) q10
WHERE inst_name = 'Yacktman Fund'
AND vi.inst_num = vh.inst_num
AND vh.ticker = mt.ticker
AND mt.m_ticker = sd.m_ticker
AND mt.m_ticker = p.m_ticker;

Take a look at the inner query in the FROM clause:
(SELECT count(*) q10_count FROM vhold vh
WHERE q1_shares = 0 GROUP BY vh.ticker) q10

I basically need the same criteria applied as the outer query. Do I
have to re-list the criteria? I'll have to do that count for 5
fields. It will make this query WAY long.......

I don't see a join with q10. Is a cross join really what you intend?

robert
.



Relevant Pages

  • Re: Messed Up Query
    ... FROM vinst vi, vhold vh, master_table mt, stock_data sd, prices p, ... Take a look at the inner query in the FROM clause: ... I basically need the same criteria applied as the outer query. ...
    (comp.databases.oracle.misc)
  • Re: Messed Up Query
    ... FROM vinst vi, vhold vh, master_table mt, stock_data sd, prices p, ... Take a look at the inner query in the FROM clause: ... I basically need the same criteria applied as the outer query. ... Is a cross join really what you intend? ...
    (comp.databases.oracle.misc)
  • Messed Up Query
    ... FROM vinst vi, vhold vh, master_table mt, stock_data sd, prices p, ... Take a look at the inner query in the FROM clause: ...
    (comp.databases.oracle.misc)
  • Re: Messed Up Query
    ... FROM vinst vi, vhold vh, master_table mt, stock_data sd, prices p, ... It will make this query WAY long....... ... Is a cross join really what you intend? ... I want to do a count on a column with it;s own criteria ...
    (comp.databases.oracle.misc)
  • Re: SQL to Linq - Left, Right and Inner Joins
    ... select distinct c.* from customers c cross join orders o ... Specifying a query with different constructs and then relying on the optimizer to make the best of it isn't optimal and will likely fail in some situations. ... Well you can easily add where clauses to each effective side of a join in LINQ: ...
    (microsoft.public.dotnet.languages.csharp)