473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

error Every derived table must have its own alias

232 100+
Expand|Select|Wrap|Line Numbers
  1. query 1=SELECT institute.state, result. * 
  2. FROM institute
  3. INNER JOIN result ON centrecode = original_c
then i want to execute query on table 1
Expand|Select|Wrap|Line Numbers
  1. SELECT state, sum( IF( PASS_FAIL = 'P', 1, 0 ) ) AS tp from query1
  2. group BY state
but when i execute it gives error

Expand|Select|Wrap|Line Numbers
  1. Error
  2. SQL query:  
  3.  
  4. SELECT state, sum( IF( PASS_FAIL = 'P', 1, 0 ) ) AS tp
  5. FROM (
  6.  
  7.  
  8. SELECT institute.state, result. * 
  9. FROM institute
  10. INNER JOIN result ON centrecode = original_c
  11. )
  12. group BY state
  13. LIMIT 0 , 30 
  14.  
  15. MySQL said:  
  16.  
  17. #1248 - Every derived table must have its own alias 
kindly help me to correct it
Nov 15 '09 #1

✓ answered by SLauren

You can try like:

Expand|Select|Wrap|Line Numbers
  1. SELECT state, sum( IF( PASS_FAIL = 'P', 1, 0 ) ) AS tp 
  2. FROM ( 
  3.  
  4.  
  5. SELECT inst.state, res. *  
  6. FROM institute inst
  7. INNER JOIN result res ON inst.centrecode = res .original_c 
  8. AS val
  9. group BY state 
  10. LIMIT 0 , 30;

1 9166
SLauren
60
You can try like:

Expand|Select|Wrap|Line Numbers
  1. SELECT state, sum( IF( PASS_FAIL = 'P', 1, 0 ) ) AS tp 
  2. FROM ( 
  3.  
  4.  
  5. SELECT inst.state, res. *  
  6. FROM institute inst
  7. INNER JOIN result res ON inst.centrecode = res .original_c 
  8. AS val
  9. group BY state 
  10. LIMIT 0 , 30;
Nov 16 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: David Good | last post by:
We have a network running both Win2k and Win2k3 webservers and our web sites reside on a UNC network share that happens to be a Network Appliance NAS. Since moving the web root to the network...
8
by: Dave Smith | last post by:
I am running 7.2 and when doing a vacuum I am getting the following error.... ERROR: Cannot insert a duplicate key into unique index pg_statistic_relid_att_index Where do I start to fix...
5
by: Santiago Ordax Solivellas | last post by:
Hi. We have almost all our tables defined on library lib1 and some on lib2. We have alias defined on lib1 to access tables on lib2 so there is no need to qualify library name. Alias for tables on...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
8
by: pmud | last post by:
Hi, I am using a compare validator in asp.net application(c# code). This Custom validator is used for comparing a value enterd by the user against the primary key in the SQL database. IF the...
1
by: CSN | last post by:
Just wondering - does PG support derived tables? I'm not really sure what the difference is between them and subqueries. http://www.mysql.com/news-and-events/press-release/release_2004_32.html...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
1
by: waqasshah | last post by:
hi iam running this simple query using table,column aliases SELECT T1.student S1,SUM(T1.mark)"TOTAL MARKS" FROM ALLMARKS03 T1 GROUP BY T1.student where T1 table alias s1 column alias,ALLMARKS03...
1
by: hawaiijeff | last post by:
I have a database in Access 2003 that is attempting to insert rows from table A into table B. One of the columns in table B is a date, which is derived by taking the minimum date from table A and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.