How to count the amount of toys that every boy has (without creating any table)?

For example, there are 3 boys (boy, a boy b, boy c) and 2 types of toys (A toy, toy B).

Insert the following records:

(boy a, A toy)

(boy a toy B)

(boy a toy B)

(boy b, a toy)

So I expect to get the following statistics:


A toy
Toy B
Boy one12
b Boy10
c boy00

Notice 1: The list of boys and the list of the toy_kind are determined, that is, I can generate the phrase sql in c#, using the two lists.

Notice 2: I wish that all the columns appeared, even if a column is made up of 0. If a row of 0 as 'boy c' is displayed or not has no importance.

How to do this WITHOUT creating tables? Use sql or a procedure are OK. I had to use the result in c# to add the table to Word.

Thank you!

These data are stored in a table already?

You say "without creating table", but we don't know what that makes reference.

You are looking for something like this?

SQL > with boys like (select "boy a ' as a boy all the double union")
2 Select 'b boy' union double all the
3 select 'boy c' double
4               )
5, boys_toys as (select ' boy a "boy,"A toy"as any double union toy")
6 select 'boy a', 'toy B' from dual union all
7 if he would choose "a boy ', 'toy B' dual Union all"
8 select 'boy b', 'A Toy' go two
9                    )
10-
11 - the end of test data
12-
13. Select boys.boy
14, sum (case when toy = 'toy A' then 1 else 0 end) as the toyA
15, sum (case when toy = ' toy B' then 1 else 0 ") as toyB
boys 16
17 left outer join (boys_toys.boy = boys.boy) boys_toys
Group 18 by boys.boy
19 order by 1
20.
TOYA TOYB BOY
----- ---------- ----------
boy's 1 2
Boy b 1 0
Boy c 0 0

3 selected lines.

Tags: Database

Similar Questions

  • How to write the script of commands to send an email without installing any email program (like outlook)?

    Hello

    We are able to send emails with mapisend in the batch script. MAPIsend command works very well as we installed it in our outlook computer.

    But we need to send e-mail to batch script without having any outlook e-mail program installed. Please help us on this.

    Thank you

    Sarah B

    Don't Mob No + 91 9095286870

    MB

    Which would be better asked here

  • How to count the page that is provided on page element

    How to count the page that is provided on page element

    Hi durgeshj41842015,

    the kDocBoss has an IPageList interface with GetPageCount() function.

    Markus

  • How to reduce the amount of storage to free up more space

    How to reduce the amount of storage to free up more space

    There are several things you could do.

    Save your iPad to iTunes on a computer or create an iCloud account, find out how much storage space you need for data and if you need to buy storage space monthly, to do. Then save your iPad to iCloud.

    HOWEVER the data backup on your iPad using WiFi or Bluetooth wireless, local devices such as portable hard drives or small flash memory drives designed for use with mobile devices, like the iPad.

    Remove the applications that you use is no longer. If you start to use them in the future, you can re-download them the iOS App Store.

    Thin out / remove the amount of music and movies you have on your iPad.

    If you make a backup of your iPad, you can thin out / delete all images stored in the iOS App Photos.

    Thin out / remove all books electronic, iBooks, eMagazines, and PDF documents, you have stored on your iPad. Magazines and e-books can be redownloaded at a later date.

  • How to determine the amount of memory shipped on the PXI-5114

    How to determine the amount of memory onboard, I have on my PXI-5114?

    Thanks in advance.

    Hello

    I'm sorry I didn't know you already had the map.  There is a property for NO-Scope node to determine the total amount of available memory that we can then divide down to get the memory available per channel.  Please see the vi and help below:

    This gives a shot, just drop it in a VI that you use and if it should return your memory cards.  If you don't have a LabVIEW I can probably retrieve the purchased version by querying your serial number.

    Kind regards

    Kyle S

  • How to count the number or lines in the file

    Hi Experts,

    I'm file as source and Oracle as target. My folder that contains some data that will load the target.
    My requirement is that I want to count the number of lines that contains my folder. Please help me how to count the total number of lines in the file.


    THX,
    Sara.

    Hi Sahaveda,

    Now, I tried and it works.

    Sorry my mistake again.

    I created HR. ETL_FILE_LOG as below:

    CREATE THE TABLE HR. ETL_FILE_LOG (numero_fichier varchar2 (10))

    Below the code will run without error:

    import java.lang as lang

    import java.sql SQL

    import of java.lang.String

    Import os

    disadvantages is sql. DriverManager.getConnection ("<%=snpRef.getInfo("DEST_JAVA_URL")%>", "<%=snpRef.getInfo("DEST_USER_NAME")%>", "<%=snpRef.getInfo("DEST_PASS")%>")

    dblinks = cons.createStatement)

    File1 = Open ('c:\EMP.txt','r')

    Count = 0

    Line = file1. ReadLine()

    all online! ='' :

    Count += 1

    Line = file1. ReadLine()

    File1. Close()

    sqlQuery = "insert into HR. "The values of ETL_FILE_LOG (numero_fichier) (" + str (count) + ' ") '.

    rqQuery = dblinks.execute (sqlQuery)

    jerks. Close()

    Concerning

  • How to count the number of hit on the page, click

    Hello..
    can someone tell me...
    How to count the number of hit on the page, click

    Thanks in anticipation...

    Somethig like that?
    http://www.baigzeeshan.com/2011/12/Oracle-ADF-storing-temporary-values-in.html

  • How to count the number of nodes under each parent in any given xml

    How to count the number of nodes under each parent in any given xml. for example the xml below was
    books has 3 childern, library [1] has 4, [2] library has 6 and bookshop [3] has 2. is it possible to get the number of tags in a childnode duplicate IE library [1]
    Book1 Tagus repeated twice... vice versa. do we need to make plsql lie we can achieve through sql

    < book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    ACR < book1 > < / book1 >
    Lac < Book4 > < / Book4 >
    < / book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    ACR < book3 > < / book3 >
    ACR < book3 > < / book3 >
    tray of < bookn_1 > < / bookn_1 >
    adjusted cost base < bookn > < / bookn >
    < / book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    < / book >
    < / books >


    I tried this... query.

    Select
    XMLQUERY ('count($doc/Books/Bookstore[1]/descendant::*)' in the way of xmltype ("< books >
    < library >
    ABC < book1 > < / book1 >
    ACR < book1 > < / book1 >
    Lac < Book4 > < / Book4 >
    < / book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    < / book >
    (< / books > ')
    as 'doc' of happy return) .getNumberVal () as node_count
    of the double

    Select
    XMLQUERY ('count($doc/Books/descendant::*)' in the way of xmltype ("< books >
    < library >
    ABC < book1 > < / book1 >
    ACR < book1 > < / book1 >
    Lac < Book4 > < / Book4 >
    < / book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    < / book >
    (< / books > ')
    as 'doc' of happy return) .getNumberVal () as node_count
    of the double

    How can I get the counts for each parent in a single query

    Published by: user7955917 on August 24, 2012 07:26

    Generic function how you want the query to be.

    If the structure is known in advance, as in your example a 'books' and then a 'library' root element, it's as simple as:

    SQL> select x1.parent_id, x2.child_name, count(*)
      2  from tmp_xml t
      3     , xmltable(
      4         '/books/bookstore'
      5         passing t.object_value
      6         columns parent_id   for ordinality
      7               , child_list  xmltype path '*'
      8       ) x1
      9     , xmltable(
     10         '/*'
     11         passing x1.child_list
     12         columns child_name varchar2(30) path 'name()'
     13       ) x2
     14  group by x1.parent_id, x2.child_name
     15  order by x1.parent_id, x2.child_name
     16  ;
    
     PARENT_ID CHILD_NAME                       COUNT(*)
    ---------- ------------------------------ ----------
             1 book1                                   2
             1 book2                                   1
             1 book4                                   1
             2 bookn                                   1
             2 bookn_1                                 1
             2 book1                                   1
             2 book2                                   1
             2 book3                                   2
             3 book1                                   1
             3 book2                                   1
    
    10 rows selected
     
    

    If you want a generic solution that works without knowledge of the structure, you will need a recursive approach, and most importantly, you should know which nodes in distinct, I suppose that the leafs?

    Also, please help if you can provide the link of reference on the function name() years what are the other expression, that I can use after the path

    You can start reading the documentation: http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb_xquery.htm#CBAGCBGJ

    The clause PATH expects a XQuery expression however before 11.2, we can put only simple XPath expressions.

  • How to count the number of data records?

    Hey guys, how to count the number of records, I had on a data object variable?

    Im having a result of sql query in a variable like this:

    oDB.resolveNode("#command").query.select.value = "SELECT * FROM Customers WHERE CliNombre LIKE ' % ' + input1 +" %' ";

    oDB.open ();

    oDB.first ();

    So I need to count the number of records retrieved by this SQL query at the moment. Help please

    Then move the cursor back to the first record after you have your account.

    There is a keyword count in SQL that will allow you to get the account of your request. You can run that first - get your account, and then run the actual query to get the Recordset. This would require a separate data connection. Some examples of code.

    var xfa.event.newText = inName;
    If (inName == "") {}
    App.Alert ("you must enter a name--try again!")
    }
    var nIndex = 0;
    While (xfa.sourceSet.nodes.item (nIndex) .name! = "DataConnection2")
    {
    nIndex ++;
    }

    oDB = xfa.sourceSet.nodes.item (nIndex) .racing var (1); pertaining to the specified data connection node
    App.Alert (ODB.saveXML ("Pretty"));

    var nIndex = 0;
    While (xfa.sourceSet.nodes.item (nIndex) .name! = "DataConnection3")
    {
    nIndex ++;
    }
    var oDBCount = xfa.sourceSet.nodes.item (nIndex) .racing (1); pertaining to the specified data connection node
    Configure sql call DB to get the number of records that match the criteria

    oDBCount.nodes.item (1).query.setAttribute ("text", "commandType");
    oDBCount.nodes.item (1).query.select.nodes.item (0) .value = "Select count (*) from table1 where AcctNumber = '" + inName + "'";
    oDBCount.open)
    oDBCount.close)

    Configure sql call DB to get the specified employee number

    oDB.nodes.item (1).query.setAttribute ("text", "commandType");
    oDB.nodes.item (1).query.select.nodes.item (0) .value = "Select * from table1 where AcctNumber = '" + inName + "'";
    App.Alert (ODB. Nodes.Item (1) .saveXML ("Pretty"));

    now connect to the DB and get a recording
    oDB.open)
    oDB.close ();

    Note the SQL command use the keyword count (take a look at the oDBCount section). This will return a number of return to the cllaer. When I set up the data connection, a node count (*) that appeared there. I dragged to the form and it has created a field called count that the onus at this node. When the query is executed, the number of resulting records returns to this field. You can have hidden it so that your users can not see it and also to change the binding votes to zero, so it is not included in the data file that is submitted when the form is complete.

    Paul

  • How to determine the amount of memory was my pci-6115?

    How to determine the amount of memory was my pci-6115?

    I see two beaches of memory OR max.

    My PCI-6115 there 32 or 64 MB memory?

    Range of memory between 1: FE9F7000-FE9F7FFF

    Range of memory between 2: FE9F7800-FE9F8FFF

    It's an old part number for the Board 32 MB.

    -Christina

  • How to operate the DVD player so that I can run DRIVER RECOVERY DVD from HP?

    Separated from this thread.

    Hello

    Thanks for the reply, I clicked on the link and it shows windows...

    Here I can not open the widows of anywhere.

    How to operate the DVD player so that I can run DRIVER RECOVERY DVD from HP

    MINE IS A VERSION OF COMPAQ PRESARIO HOME ON WINDOWS VISTA

    He always goes to startup repair

    then he said not being able to correct automatically

    Under system recovery option what can I do?

    I don't want to go back to the point of origin of the memory (factory settings)

    Thank you

    Patrick

    Hello

    Have you tried using SafeMode w/command invites to perform a system restore?

    1. Press the power button to turn on the computer.
    2. In the first screen, press the f8 key repeatedly every half second until what the Windows Advanced Startup Options screen displays.
    3. Press the arrow key down until Safe Mode with command prompt is selected, and then press ENTER. Wait while the Windows Load system files. The Windows log on screen is displayed.
    4. At the command prompt, type rstrui.exe, and then press ENTER. Wait a few moments for the system to open restore window.
    5. Follow the on-screen instructions to perform a system restore.

    You have now returned the computer to a previous restore point using Mode safe mode with command prompt.

    Using Microsoft System Restore (Windows Vista)

    http://h10025.www1.HP.com/ewfrf/wc/document?cc=us&LC=en&DLC=en&docName=c00807369

    You also have the option to create a backup of your files when you perform a recovery

    http://h10025.www1.HP.com/ewfrf/wc/document?cc=us&DLC=en&docName=c00809678&LC=en&product=18703#n405

  • How to determine the amount of ink in the cartridge of 920 ink

    I'm operating a HP OfficeJet 6500 has more with HP 920 cartridges. The operating system is Windows XP. How to determine the amount of ink in the cartridges. I get a "low ink" memo of the printer, even if it's too late.

    Hello

    In the menu, press the right arrow once, then you should see an icon 'meter ink' it will show you an estimated ink level.

  • How to make the color of ScrollBar that are created using the css code is displayed in Windows 8

    I wish I could understand how to get the color of ScrollBar that are created using the css code appears on my web design theme games. But I can't see them in Windows 8. Is there something that I need to enable to see colorful scroll bars? I'm used to be able to see them on my Windows XP computer. It is important for me because a lot of people like models with colorful scroll bars.

    Open the Tools menu and turn on "Compatibility view" to do.  Note that this works only in the desktop version of Microsoft Internet Explorer.

  • How to count the number of pages on the spread

    How to count the number of pages on the spread

    #include "ILayoutControlData.h".

    #include "ILayoutUIUtils.h".

    #include "ISpread.h".

    InterfacePtr layoutData (Utils()-> QueryFrontLayoutData());

    If (layoutData)

    {

    UIDRef spreadRef is layoutData-> GetSpreadRef();.

    InterfacePtr activeSpread (spreadRef, UseDefaultIID ());

    Int32 count is activeSpread-> GetNumPages();.   Number of pages of active propagation.

    }

  • How to increase the amount of memory to the host system?

    Hello gentlemen,

    I am new to VMware ESXi 5, and I want to know how to increase the amount of memory for the host system?

    I saw in the Configuration menu of the host, my ESXi host has only 77.3 MB. I think it's wrong, it's too little amount of memory dedicated to the host system. It is not a (Properties) button after I was able to change the amount of memory host system.

    Please, be so kind, help me!

    Thanks in advance!

    Welcome to the community,

    where do you see this amount of memory?

    The total amount of memory installed on the host can be seen in the summary, tab (resources) with the host country is selected in the inventory.

    André

Maybe you are looking for

  • Analysis tool ALM to drop the names of parameters

    Hello We use ALM (12.20) analytical tools to create reports of test cases and test steps details.  When we run the reports, all the parameter names in the test steps (e.g. >) are missing and only "" shows where is the name of the parameter. Someone k

  • Why are they not icons and files in the windows folder

    No matter what folder/window that opens like the Control Panel, documents folder opens but is a blank window.  No icons or files.  Programs and files are all there, but could not get to them from any window.  Why windows appear white?

  • license of Captivate

    I just want to learn that captivate license is for a year or a lifetime?

  • liquefy shows a highlighted autour area where I edited.

    liquefy shows a highlighted area autour where I edited and after I press OK. This just started to happen after I've just updated Photoshop today

  • How to get multiple queues in a single queue in weblogic?

    HelloI have three queue q1, q2, q3, in which the message is posted. Is it possible to route the receiveing all message queues three to the queue that is unique so that I can create only a single MDB who will listen to this new queue instead of creati