Outputing a query

I thought I used to be able to do this but since I have not done it for awhile I forgot how to do it.
I have a query result that looks like this:
Categories    Course_Name  Course_No  Course_level
Language     English             E100001        Intro
Language     English             E20001        Intermediate
Language     English             E30001        Advance
Language     Spanish           S10001        Intro
Language     Spanish           S20001        Intermediate
Language     Spanish           S30001        Advance
Art                 Piano               P11001       Intorduction
Art                 Piano               P21001       Intermediate
Art                 Piano               P31001       Advance
I need to output this query in a table so when user look at this table, category will only showed once:
Categories    Course_Name  Course_No  Course_level
Language     English             E100001        Intro
                     English             E20001        Intermediate
                     English             E30001        Advance
                     Spanish           S10001        Intro
                     Spanish           S20001        Intermediate
                     Spanish           S30001        Advance
Art                 Piano               P11001       Intorduction
                     Piano               P21001       Intermediate
                     Piano               P31001       Advance
I used table but I can' get it  right, can anyone help, thank you!!
<table>
  <tr>
     <td>Category</td>
     <td>Course Name</td>
     <td>Course Number</td>
     <td>Course Level</td>
   </tr>
  <cfquery name="GetCourses datasource="#dsn#">
   select * from program 
   order by category
  </cfquery>
<cfoutput query="GetCourses">
  <cfquery name="GetCategory datasource="#dsn#">
   select distinct categorry from program
  </cfquery>
  <tr>
     <td>#GetCategory.Category#</td>
     <td>#Course_Name#</td>
     <td>#Course Number#</td>
     <td>#Course Level#</td>
   </tr>
</cfquery>    
</table>

<cfoutput query="GetCourses" group="Categories">
     #Categories#
     <cfoutput>
          #Course_Name# #Course_No# #Course_Level#
     </cfoutput>
</cfoutput>

Similar Messages

  • How to output a query results into a text file

    How to output a query results into a text file instead of outputing it to the screen..
    is there a way for us to write a SQL query which specifies to output the query results to a text file.
    Pls let me know how to do it
    Thanking u in advance
    regards
    Muraly

    Muraly,
    If you are using SQL*Plus 8.1.6 or later, you can also spool output to a file in HTML format, eg
    SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON
    SPOOL c:\temp\report.html
    SELECT DEPARTMENT_NAME, CITY
    FROM EMP_DETAILS_VIEW
    WHERE SALARY>12000;
    SPOOL OFF
    SET MARKUP HTML ENTMAP OFF
    In iSQL*Plus 9.0.1 (the browser-based interface to SQL*Plus) onwards, you can also send the HTML output to a new web browser window, or an html file -- much easier than the command line method.
    Alison

  • Change display Date format from 06.2011 to june 2011 in output of Query

    Hi All,
                Change display Date format from 06.2011 to june 2011 in output of Query  Execution. i used time charcteristics 0calmonth in query, output display is coming 06.2011, i want to display output in june 2011 format, anyone tell me how to convert this Date format.

    Hi Nandish,
    as tibollo said you just need to mark 0CALMONTH with text in RSD1.
    Kindly note that you don't need to do data load for this object.
    It will automatically derive by system.
    Just change the Info object 0CALMONTH in RSD1, Go to Master Data/text column and check mark on with text.
    Then activate it.
    Regards,
    Ashish

  • Output select query in OLEDB Command

    Hi I am trying to write a simple output query to get the Count of rows  in OLE Db Commnad Adavnced editor and getting error. Please help!
    Declare @Count INT;
    Select @Count(*) AS ? FROM <tablename>WHERE Column 1  =?  AND Column2 = ?
    Please help as this is my first project!
    Thanks in advance.

    Not sure what went wrong, but the typical pitfall is not mapping the parameters properly, so see this:
    http://blogs.msdn.com/b/msdnts/archive/2006/11/17/amazing-ssis-parameters-in-execute-sql-task.aspx
    Arthur My Blog

  • Output CFC query to Flex app

    I have a CFC which simply calls the DB and returns the
    results to the Flex app.
    CFC:
    <cfcomponent>
    <cffunction name="runQuery" output="false"
    access="public" returntype="Query">
    <cfquery name="qry_login" datasource="EWPROJ">
    SELECT *
    FROM ROBERTTEST
    </cfquery>
    <cfreturn qry_login>
    </cffunction>
    </cfcomponent>
    Simple enough.......
    Here is my Flex file...
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" creationComplete="initApp();">
    <mx:Script>
    <![CDATA[
    import mx.rpc.events.ResultEvent;
    import mx.collections.ArrayCollection;
    [Bindable]
    private var qry_result:ArrayCollection;
    private function initApp():void //first thing to load
    callCFC.runQuery()
    private function resultHandler(event:ResultEvent):void
    var qry_result:ArrayCollection = new ArrayCollection();
    //New Array Object called p1
    qry_result.source=event.result as Array;
    trace(qry_result);
    ]]>
    </mx:Script>
    <mx:RemoteObject id="callCFC" destination="ColdFusion"
    source="CFIDE.samples.FlexToCFC.CFC.myCFC"
    result="resultHandler(event)"
    showBusyCursor="true" />
    </mx:Application>
    my problem is within the [resultHandler] I want to simply
    create a variable that will contain my results of the object I
    passed so I can trace it to the screen.... I know that the object
    is returning correctly, by tracing result.event. What am I doing
    wrong here, cause it shows nothing.
    I'm guessing that my problem is that I am not putting the
    object into some sort of array or string where I can access it...
    How do I do this correctly? Thanks everyone.

    Ahhh,,, yes, I appologize. I will make better headings next
    time.. Okay, I tried your solution and it printed out what I wanted
    and more. SWEET!! Now I think all I need to do is put it in an
    associated array so I can reference things better. Not sure yet,
    but I'll play with it. Thanks again... Genius! BTW, here is the
    output when I ran it:
    mx.collections::ArrayCollection)#0
    filterFunction = (null)
    length = 6
    list = (mx.collections::ArrayList)#1
    length = 6
    source = (Array)#2
    [0] (Object)#3
    NAME = "Rob Capilli"
    TYPE = "Male"
    [1] (Object)#4
    NAME = "Meatball"
    TYPE = "Cat"
    [2] (Object)#5
    NAME = "Sanket"
    TYPE = "male"
    [3] (Object)#6
    NAME = "Sarah"
    TYPE = "Female"
    [4] (Object)#7
    NAME = "1"
    TYPE = "1"
    [5] (Object)#8
    NAME = ""
    TYPE = ""
    uid = "21B5BECE-6A2E-6940-9543-E830E43DAAFA"
    sort = (null)
    source = (Array)#2

  • ABAP Coding Help for Subtotal type output - SAP Query

    I've created a SAP Query to display a stock overview by storage type using the table LQUA.
    The output that I get is:
    Material
    Description
    Plant
    WHN
    SLOC
    Storage Type
    Batch
    GR Date
    Available stock
    2057 
    STRAWBERRIES
    BP01
    100
    0088
    200
    0001081766
    17.06.2014
    225
    2057
    STRAWBERRIES
    BP01
    100
    0088
    200
    0001081766
    17.06.2014
    720
    2061
    VOSTIZZA CURRANTS
    BP01
    100
    0088
    200
    0001081272
    17.06.2014
    1,000
    2061
    VOSTIZZA CURRANTS
    BP01
    100
    0088
    200
    0001081272
    17.06.2014
    1,000
    2061
    VOSTIZZA CURRANTS
    BP01
    100
    0088
    200
    0001081272
    17.06.2014
    1,000
    2061
    VOSTIZZA CURRANTS
    BP01
    100
    0088
    200
    0001081272
    17.06.2014
    1,000
    I can get a subtotal for each Material, batch and GR date combination by using the ALV grid functionality.
    This method adds too much clutter to my query and can't be easily manipulated in Excel afterwards for what I want. I want to condense the results down and just keep a cumulated available stock, e.g:
    Material
    Description
    Plant
    WHN
    SLOC
    Storage Type
    Batch
    GR Date
    Available stock
    2057 
    STRAWBERRIES     
    BP01
    100
    0088
    200
    0001081766
    17.06.2014
    945
    2061
    VOSTIZZA CURRANTS
    BP01
    100
    0088
    200
    0001081272
    17.06.2014
    4,000
    How can this be done?

    Hi,
    Please try to use STATISTICS in your SAP Query. you can sort and add your value based on condiiton then it will be show you collect value in SQ01.
    Please see the below documents for STATISTICS
    https://help.sap.com/saphelp_erp2004/helpdata/en/d2/cb4263455611d189710000e8322d00/content.htm
    Regards,
    Prasenjit Mishra

  • Trouble outputting all query results

    For some reason this code doesn`t output all the results only
    the first one. How can I can it working I did try a way that output
    all the results the same amount of times as there are Referer
    entries in the db which is obviously not what I want. What is the
    way to do thisso that it is cfoutput right? Thank you very much
    <cfquery name="qrysales">
    SELECT Referer
    FROM clientinfo
    </cfquery>
    <cfoutput><cfif len(qrysales.Referer)>
    <cfif find("?", qrysales.Referer)>
    <cfset paramList = "q,p,terms,search,query,qkw">
    <cfset strStart = find("?", qrysales.Referer)>
    <cfset referer_queryString =
    right(Referer,len(qrysales.Referer)-strStart)>
    <cfset referer_url =
    left(qrysales.Referer,(strStart-1))>
    <cfloop list="#referer_queryString#" delimiters="&"
    index="i">
    <cfif listfind(paramList,listfirst(i,"="))>
    <cfset variables.searchPhrase = listlast(i,"=")>
    </cfif>
    </cfloop>
    </cfif>
    </cfif>
    <cfif isdefined("variables.searchPhrase")>
    <cfoutput>#variables.searchPhrase#</cfoutput>
    </cfif>
    </cfoutput>

    The code works fine using the querynew values. When I use the
    db cfquery then I get the results output over and over again. Why
    is that?! Thanks
    <!---
    <cfquery name="qrysales">
    SELECT Referer
    FROM clientinfo
    </cfquery>--->
    <h3>QueryNew Example</h3>
    <cfset qrysales = QueryNew("referer")>
    <!--- make some rows in the query --->
    <cfset newRow = QueryAddRow(qrysales, 4)>
    <!--- set the cells in the query --->
    <cfset temp = QuerySetCell(qrysales, "referer", "
    http://search.live.com/results.aspx?q=environment+property+study&FORM=SSRE2
    ", 1)>
    <cfset temp = QuerySetCell(qrysales, "referer", "
    http://search.live.com/results.aspx?q=healthcare&mrt=en-us&FORM=LIVSOP",
    2)>
    <cfset temp = QuerySetCell(qrysales, "referer", "
    http://www.google.co.uk/search?q=grande+rio&sourceid=navclient-ff&ie=UTF-8&rlz=1B2GGFB_enG B251",
    3)>
    <cfset temp = QuerySetCell(qrysales, "referer", "
    http://www.google.de/search?q=Rio-Grande&ndsp=20&hl=de&ie=UTF-8&oe=ISO-8859-1&start=30&sa= N",
    4)>
    <cfoutput query="qrysales"><cfif len(#Referer#)>
    <cfif find("?", #Referer#)>
    <cfset paramList = "q,p,terms,search,query,qkw">
    <cfset strStart = find("?", #Referer#)>
    <cfset referer_queryString =
    right(Referer,len(#Referer#)-strStart)>
    <cfset referer_url = left(#Referer#,(strStart-1))>
    <cfloop list="#referer_queryString#" delimiters="&"
    index="i">
    <cfif listfind(paramList,listfirst(i,"="))>
    <cfset variables.searchPhrase = listlast(i,"=")>
    </cfif>
    </cfloop>
    </cfif>
    </cfif>
    <cfif isdefined("variables.searchPhrase")>
    #variables.searchPhrase#
    </cfif>
    </cfoutput>

  • Output of query gives unwanted whitespace

    Hi
    A client asked to create a small application in CF. I have no
    experience with cf and now I have a problem.
    I'm querying a database and I want to put the results of the
    query on screen. Inititally I used the cfoutput tag to output the
    entire query to the screen, but it gives me a white space between
    the different records. I don't want that since it's html code that
    I'm putting on the screen.
    I also tried looping through the query myself with cfloop and
    then use the output tag
    How can I prevent the white space between the different
    records ?
    thx !

    Let me check if I get you right. So, you are actually trying
    to save your HTML by parts into different rows in your db. After
    that, you extract all the rows and use the cfloop to display all
    the rows, which will sum the parts of your HTML. You should
    consider 2 things:
    1.) Basing on your query pagina_inhoud, I don't see any ORDER
    BY clause. I think when your query doesn't have an ORDER BY,
    sometimes row 2 can come first before row 1. In this case, there is
    a possibility that your HTML might be displayed incorrectly. I
    think you should consider the ordering/sorting of your rows when
    your data is returned from db. I mean, you should put another field
    which will determine the order/sort of the returned rows so as not
    to misplace some parts of your HTML when outputting the data.
    2.) Another thing is the way you output your data. The
    problem is when there are spaces before and after your
    <cfoutput> tag as shown below:
    [spaces here]
    <cfoutput>#pagina_inhoud.inhHtml#</cfoutput> [spaces
    here]
    The format above can also cause your HTML code to have spaces
    in between. In order to avoid this, make sure there are no spaces
    on those part of your code. To do this, use cfsetting tag in your
    output as shown below.
    <cfsetting enableCFoutputOnly = "yes"> <!--- this
    will block any HTML output(including spaces) after this tag and
    those that are outside the cfoutput tags --->
    <cfloop
    query = "pagina_inhoud"
    startRow = "1"
    endRow = "#pagina_inhoud.RecordCount#">
    <cfoutput>#pagina_inhoud.inhHtml#</cfoutput>
    </cfloop>
    <cfsetting enableCFoutputOnly = "no"> <!--- change
    back to "no" to make sure that HTML outputs after this tag are
    displayed --->

  • Same Cursor Output - Different Query

    I am writing 2 cursors.
    Cursor 1 which gives me A,B,C,D columns as output.
    Cursor 2 gives me same A,B,C,D columns as output.
    But the Logic to calculate inside the cursor Select Query is different.
    I need to insert both A,B,C,D from Cursor 1 and Cursor 2 in same table by looping. Just curious to know do we have any way to insert the data by using same loop. Know it is impossible. Giving a try for any other solution.
    Because I have 5 different cursors with same columns to be fetched and to insert in same table.
    Planning to write a common insert script.

    select a,b,c,d from ... query 1 where code in ('AB','CD')...
    UNION ALL
    select a,b,c,d from ... query 1 where code = 'EF'...
    UNION ALL
    select a,b,c,d from ... query 1 where code NOT IN ('GH')
    But if only Code 'AB' is present, will that be fine to execute 'EF' query and 'GH' query also? All queries will have a minimum of 10 tables joins within 2 schema. If we write the condition before it will skip executing the 'EF' query and 'GH' query.
    Which option is better?I do not see any problem with including the CODE conditions in the Select queries until the tables in the query contains the CODE column. If there is no table with CODE column, then you may have to include it somehow (Assuming different tables for each query).
    Fine or not, it is for you to decide. If you use UNION/UNION ALL, all the queries shall be executed and the data, if present, shall be inserted into the target tables.
    Moreover
    select a,b,c,d from ... query 1 where code in ('AB','CD')...AND
    select a,b,c,d from ... query 1 where code NOT IN ('GH')Do you not think it will return Duplicate records? Query where CODE NOT IN ('GH') would include CODES 'AB', 'CD', right? And using UNION ALL does not eliminate duplicates. So, if you have a Primary/Unique key, you are almost certain to encounter an error. Isn't it?
    As an alternative, I think, you can use the Multitable Inserts as below:
    INSERT ALL|FIRST         ----------> Use as suitable. ALL will process each condition irrespective of its TRUTH value; FIRST will stop evaluating the conditions after first match. If you do not specify, Default is ALL.
      INTO target_table (column_list)
    VALUES (column_list_from_select_stmt)
    select column_list, CODE
      from source_table(s);For more information on MultiTable inserts, Read Here.
    Examples here.

  • D51wkdmp.exe output format query

    When i run d51wkdmp.exe to get the report details ,the syntax i see is
    d51wkdmp <Workbook_Name> <Output_File> <DB|FS> <Connect_String> <Eul_Schema> -f
    and the example given is "d51wkdmp "Video Tutorial Workbook" video.txt DB disco/[email protected] disco "
    where video.txt is the output file.can i create an xml output file i.e Can i give the cmd like
    "d51wkdmp "Video Tutorial Workbook" video.cml DB disco/[email protected] disco "?
    Will it give me output in an xml format or .txt is the only output format that can be used?

    Hi
    The utility will only give you output in text format I'm afraid. It's just a quick way of seeing what a workbook is up to.
    Best wishes
    Michael

  • Direct the output of query results to a table

    Hi,
    I would like to know as how to transfer the results of a query
    to a table.
    eg:
    Select * from employee into <Tmp_table>
    Hence I would have a copy of employee table in the newly created
    Tmp_table.
    Thanks in advance
    Azeez

    Oracle does this so well as:
    create table <Tmp_table> as select * from employee
    Hopefully I understood your question correctly.

  • Output of Query--Little urgent

    Hi All,
    I had Emp Table as follows.
    Emp table
    Empid DeptId Hiredate Salary
    1 100 10/1/2006 80,000
    2 100 1/1/2007 100,000
    3 100 2/1/2007 100,000
    4 100 3/1/2007 90,000
    5 100 4/1/2007 200,000
    6 100 5/1/2007 80,000
    7 200 6/1/2007 10,000
    8 200 7/1/2007 20,000
    9 200 8/1/2007 30,000
    10 200 9/1/2007 40,000
    Pls provide the out put for the following queries.
    1)Select count(*),Empid,DepItd
    From EMP
    Groupby empid,DeptId;
    2)Select Count (*) ,EmpId,Depid
    from Emp
    Groupby DepiId;
    Thank You,
    rampa.

    Pls provide the out put for the following queries.Why don't you check it yourself ?
    Correct the queries first. There is no space between Group and By. EmpId is not in Group By in the second query.
    And what is that you want to achieve and what is the help you need?? Be more clear and specific.

  • Output of query

    what is output of this????
    Shift l_deviation-dev_temp left deleting leading space.
    where l_deviation is an internal table.

    Hi, the o/p of this statement might give rise to an error, if the internal table is not declared with the header line and this statement is not included in a loop.
    For eg., l_deviation-dev_temp = '        12345'.
    Then after executing the shift statement:
    l_deviation-dev_temp = '12345'.i.e., all the leading spaces before 12345 would be deleted giving rise to only non-space characters in the internal table.
    The field l_deviation-dev_temp should be of type 'C' else it will give an error.
    Reward points if useful,
    Thanks,
    Archana

  • Output of query results to users in AIX menu

    We have users logging into AIX. Upon login they see menu options 1-xx.
    We would like a menu option to query the database and display the results on the user's screen.
    Thanks,
    Saira

    Oracle does this so well as:
    create table <Tmp_table> as select * from employee
    Hopefully I understood your question correctly.

  • Output Types Query

    Hi All,
    I have got a requirement that once the status of the shipment is changed to loading end (Transaction VT02N) the partner function should receive a mail.
    What I thought was to write the code in the user exit.
    But the client is thinking using the output types.
    My question is that how can I pass the shipment number from the output types to my code?
    what will be the interface between the Output type and my code?
    Please help
    Dnyanesh

    Hi,
    For every condition type which is triggered based on some business logic, an entry is stored in table NAST and TNAPR. Refer to these two tables you can find the Document Key and further you can refer to the IDOC`s control record. First step is that you`ll have to identify the output type that is configured for the shipment transaction.
    Reward if helpful.
    Regards

Maybe you are looking for