473,383 Members | 1,880 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,383 software developers and data experts.

subqueries

Helo All!

Got a problem. Is it possible to select fields from a subquery? I have seen different types of subqueries but I don't think i could use them.
I can not create views so it is out of question.
This is my query and it is supposed to be my subquery:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT POROW_AVSTEM.RUNDATE, POROW_AVSTEM.STOCKNO, POROW_AVSTEM.PONO, POROW_AVSTEM.POWDATE, POROW_AVSTEM.DELDATE, POROW_AVSTEM.VENDNO, POROW_AVSTEM.OTYPE, POROW_AVSTEM.ROWSTATUS, POROW_AVSTEM.POROWPOS, POROW_AVSTEM.PARTNO, POROW_AVSTEM.QTYPO, POROW_AVSTEM.QTYDEL, POROW_AVSTEM.POROWAMT, POROW_AVSTEM.POPRLCW, POROW_AVSTEM.CZPOCLAIMNO, POROW_AVSTEM.PODELTYPE, POROW_AVSTEM.INVREFNO, decode(extract(YEAR FROM DELDATE), '', extract(YEAR FROM POWDATE), extract(YEAR FROM DELDATE)) AS YEAR, decode(extract(MONTH FROM DELDATE), '', extract(MONTH FROM POWDATE), extract(MONTH FROM DELDATE)) AS MONTH, decode(CLASS4, 'G', 'ORD', 'FRUKT') AS FRUKT, decode(extract(MONTH FROM DELDATE), '', extract(MONTH FROM POWDATE), extract(MONTH FROM DELDATE)) || '.' || decode(extract(YEAR FROM DELDATE), '', extract(YEAR FROM POWDATE), extract(YEAR FROM DELDATE)) AS MONTHYEAR, STOCK.STOCKNAME, decode(OTYPE, '20', 'Retur', decode(ROWSTATUS, 130, 'Reklamasjon', 'Uavstemte Varer')) AS TYPE, decode(DELDATE, '', POWDATE, DELDATE) AS DATO, OTYPE || '-' || ROWSTATUS AS STATUS
  3. FROM (POROW_AVSTEM INNER JOIN PART ON POROW_AVSTEM.PARTNO=PART.PARTNO) INNER JOIN STOCK ON POROW_AVSTEM.STOCKNO=STOCK.STOCKNO
  4. GROUP BY POROW_AVSTEM.RUNDATE, POROW_AVSTEM.STOCKNO, POROW_AVSTEM.PONO, POROW_AVSTEM.POWDATE, POROW_AVSTEM.DELDATE, POROW_AVSTEM.VENDNO, POROW_AVSTEM.OTYPE, POROW_AVSTEM.ROWSTATUS, POROW_AVSTEM.POROWPOS, POROW_AVSTEM.PARTNO, POROW_AVSTEM.QTYPO, POROW_AVSTEM.QTYDEL, POROW_AVSTEM.POROWAMT, POROW_AVSTEM.POPRLCW, POROW_AVSTEM.CZPOCLAIMNO, POROW_AVSTEM.PODELTYPE, POROW_AVSTEM.INVREFNO, decode(extract(YEAR FROM DELDATE), '', extract(YEAR FROM POWDATE), extract(YEAR FROM DELDATE)), decode(extract(MONTH FROM DELDATE), '', extract(MONTH FROM POWDATE), extract(MONTH FROM DELDATE)), decode(CLASS4, 'G', 'ORD', 'FRUKT'), decode(extract(MONTH FROM DELDATE), '', extract(MONTH FROM POWDATE), extract(MONTH FROM DELDATE)) || '.' || decode(extract(YEAR FROM DELDATE), '', extract(YEAR FROM POWDATE), extract(YEAR FROM DELDATE)), STOCK.STOCKNAME, decode(OTYPE, '20', 'Retur', decode(ROWSTATUS, 130, 'Reklamasjon', 'Uavstemte Varer')), decode(DELDATE, '', POWDATE, DELDATE), OTYPE || '-' || ROWSTATUS;
  5.  
Thx in advance!!!!!
Aug 15 '05 #1
1 2281
Niheel
2,460 Expert Mod 2GB
That is one big query! Maybe a short explanation of what you are trying to accomplish would be good too.
Aug 15 '05 #2

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

Similar topics

6
by: pete | last post by:
Been banging my head against the wall with subqueries. Even simple stuff like this fails: SELECT CompanyName FROM tblcompanies WHERE CompanyName IN (SELECT HostName FROM tblhosts) Am I...
6
by: Daniel Elliott | last post by:
Hello, I was wondering if anyone would be able to help me with a problem I'm having. I'm trying to use the following query: SELECT Distinct c.site_id FROM campsite c WHERE c.site_id NOT IN...
5
by: Nick | last post by:
Im moving a development app (MySQL 5.0) to a different server which runs MySQL 4.0.20-standard. I am getting errors on queries that have subqueries such as... SELECT id FROM table1 WHERE id IN...
2
by: Kevin | last post by:
While converting SQL statements for a database change, I discovered a big performance hit in MYSQL with subqueries vices Sybase. I'm hoping that someone might be able to help me understand why? ...
2
by: CSN | last post by:
Is there much difference between using subqueries and separating out them into separate queries? __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building...
2
by: orin | last post by:
Hi all, I've seen mention that you can use nested subqueries down to as many levels as you like but whenever I run the following: select * from table1 where tab1ID in (select tab1ID from...
2
by: psuaudi | last post by:
I have a main query that I would like to call two different subqueries. In MS Access, I usually just save the two subqueries as separate queries which are then called by a third separate and main...
4
by: muzu1232004 | last post by:
Can anyone explain me when we use correlated subqueries rather than nested subqueries. Do all the correlated subqueries can be written in nested subqueries form as well ? What are the major...
0
debasisdas
by: debasisdas | last post by:
Using Subqueries ================== The sub query is often referred to as a nested SELECT, Sub - SELECT, or inner SELECT statement. The sub query executes once before the main query. The...
1
by: lizandra | last post by:
Greetings, I am a newbie, I have been working to extract data from a basic sales db and trying to decide when I should use joins and when I should use subqueries. Much of what I read online says...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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...

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.