sql - MySQL View, Union and Group By -


I am trying to write this SQL query:

  t1.tms_id, t1 Choose as Ktms_name, (select t1.Pts t.tms_id, t.tms_name, SUM tb_league as (points as s.lsc_1stscore) T, L, g in tb_game, tb_score as tb_team as Where s (t.tms_id = l.lgs_1stplace) and (l.fk_lsc_id = s.lsc_id) AND (t.fk_gms_id = g.gms_id) AND (g.gms_id = 1) GROUP by T.T.M.S. _NA) Select T1 Union T2 TMS_ID, T2 TMS_Name, T2. The PTS (t.tms_id, t.tms_name, SUM (as selected s.lsc_2ndscore) points t, tb_league L, g as tb_game, as tb_score as the tb_team where (t.tms_id = L.lgs_2ndplace) and (l.fk_lsc_id = S.lsc_id) AND (t.fk_gms_id = g.gms_id) AND (g.gms_id = 1) GROUP by T.TMSS_NA) T2 Union T3. tms_id, T3.tms_name, the T3.Pts (SELECT t.tms_id, t .tms_name, (s.lsc_3rdscore) L as tb_league, g as tb_game, as the sum of points tb_score as tb_team where s (T.tms_id = l.lgs_3rdplace) and (l.fk_lsc_id = s.lsc_id) and (t.fk_gms_id = g.gms_id) and (g.gms_id = 1) group TTMs _name) Select t3 union t4.tms_id, tb_league as T, L as the number (t.tms_id, t.tms_name, SUM (select s.lsc_4thscore) as t4.tms_name, in the form of village tb_game, the tb_team as as tb_score t4.Pts S Whaiiari (t.tms_id = l.lgs_4thplace) and (l.fk_lsc_id = s.lsc_id) aND (t.fk_gms_id = g.gms_id) and (g.gms_id = 1) TTY order by the group DTSC   

I will add a group to this question, before the Pts DESC by the final order specifications , But GROUP BY TMS_id (example) add And, show me the same results.

A friend advises me to create a view, but when I try to show this error:

# 1349 - Select the FRM section

And I do not really know what a subclass is (I was searching and I did not really understand). How can I reconstitute or repair this QUERY to use

  remove   

Am I t1.tms_id, select t1.tms_name, the t1.Pts (, t.tms_name, SUM (as points s.lsc_1stscore) tb_league as T, L, tb_game as g, t with tb_score as tb_team .tms_id selected as S where (t .tms_id = l.lgs_1stplace) aND (l.fk_lsc_id = s.lsc_id) aND (t.fk_gms_id = g.gms_id) aND (g.gms_id = 1) GROUP T-Tims_nam ) T1

The following is a sub query from a SQL statement.

  select t.tms_id, t.tms_name, as SUM (s.lsc_1stscore) as Tb_team T from PTS, tb_league as l, g, where tb_score form tb_game (t .tms_id = l.lgs_1stplace) and group by (l.fk_lsc_id = s.lsc_id) and (t.fk_gms_id = g.gms_id) and (g.gms_id = 1) t. Tms_name   

Use subqueries within mysql views to create each subquery in one view and then use that view instead of a subquery.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -