Best way to get different counts on the same column by using a query.

Hello

I try to get three different counts of the values for a specific ID on a table.  In other words, I have an Id if 1-123 and 20 records with that ID in this table, which have a value of 'Y' or 'n'.  I'm looking for the number of each of these values for every 20 rows, but also a number of total values of tag values using the function count in a single query.

In this spirit, I would like to see a result set as follows.

Example of result set:

1-123 5 15 20

I thought that I would be able to do this by using the following query below, but it didn't work and I get a ' error absent expression.  If anyone can provide guidance on my query below or any other way to reach my goal I would really appreciate it.

Query:

Select a.par_row_id,

countOfTagsNo.TagsNo as 'Tags not selected. "

countofTagsYes.TagsYes as 'Tags selected. "

countOfTagsTotal.TotalTags as 'Total Tags'

of siebel.s_src_xm.

(select par_row_id, count (attrib_08)

of siebel.s_src_xm

where type = 'AOI Tags' and attrib_08 = 'n')

countOfTagsNo,

(select par_row_id, count (attrib_08)

of siebel.s_src_xm

When type = "AOI Tags' and attrib_08 = 'Y')

countofTagsYes,

(select par_row_id, count (attrib_08)

of siebel.s_src_xm

When type = 'AOI Tags' and (attrib_08 = 'Y' or attrib_08 = 'n'))

countOfTagsTotal

where a.par_row_id = countOfTagsNo.par_row_id and

a.par_row_id = countofTagsYes.par_row_id and

a.par_row_id = countOfTagsTotal.par_row_id

A.par_row_id group;

Thanks in advance.

Chris

Hi Chris,

I'm not sure that's what you want but you had probably better counting with nested decode (or case):

Select a.par_row_id,

Count (case when type = 'AOI Tags' and attrib_08 = ' don't then 1 end) as "Tags not selected."

Count (case when type = 'AOI Tags' and attrib_08 = 'Y' then 1 end) as "Tags selected."

Count (case when type = 'AOI Tags' and (attrib_08 = 'Y' or attrib_08 = 'n') then 1 end) as 'Total Tags.

of siebel.s_src_xm

A.par_row_id group;

Tags: Database

Similar Questions

  • Is there a way to create a button etc to get different views of the same page?

    I have a page full of product images and wants to give the viewer an option to choose the size of the images on the page. So far, I just had two different pages with the same images and created a hyperlink button to switch between views. The reason why I want to get the two points of view on the same page, is I want to use the same name for each page. Muse won't let me create two pages with the same name, so now I have a parent page "Products" (with large images) and its child page "products 2" (with the small images) with a hyperlink linking them. "» This also creates a problem in the menus, since the 'product 2' does not have the active menu bar.

    I have the same problem with the creation of the site in different languages. I would like to make a simple drop-down list with options "Suomi" and "English". What I have to create two different sites in two different languages and have just the hyperlink connect for example home pages?

    Thanks for the tips!

    You can use any number of widgets to create online pop-overs / hover pods / galleries. Lightbox to the ToolTip, anything is possible. The language issue to indeed create individual sites and crosslink them.

    Mylenium

  • The graphics of my site uses Web of Muse are in different places on my HD, is there an easy way to get back them in the same folder?

    As the title says I made the mistake of putting different graphics on my website from different areas on my hard drive, is there an easy way to put them all in the same directory? Or I have to do it manually?

    Always keep all files in the same folder, very important.

    You can move them to the same folder, then right-click and select "link again assets" then find it.

    Muse is quite good on discovery than other assets after that, it should automatically find all other assets in the folder you move them too.

    otherwise you will have to connect manually, one by one

  • Different guests on the same column

    Gurus:

    I have a requirement where we need to have Date guests separated for 4 different promotions.
    Now, I was thinking about the presentation configuration variable, but then it does not work with 'Between' condition.

    So how can I compare a fact for 4 different promotions (Sun) with 4 dates different (Sun) in the same report?

    I don't know if this is possible.
    Please help me.
    Thank you.

    Vinay

    I'm not sure that I understand your question completely, but it seems you need to get the same value (say sale) measure for 4 different dates in the same table.

    My suggestions would be to create dims again and use union all with each union report report led at different times of Sun.

  • A target table is in charge of two different sources but the same columns, but a source is one database and another in a flat file.

    We all hope you are doing well.

    I have a business problem to implement in ODI 11 G. It's here. I'm trying to load a target table from two sources that have the same column names. But a source is to the file format and the other is in the Oracle database.

    That's what I think I'll create two mappings in the same interface by using the Union between the sources. But I don't know how the interface would connect to different logical architecture to connect to two different sources.

    Thank you

    SM

    You are on the right track, all in a single interface. Follow these steps

    (1) pull model of your data in the designer of the source file and your table model target to the target pane.

    (2) all relevant columns map

    (3) in the source designer to create a new dataset and choose as the UNION join type (this will create a separate tab in the source designer pane)

    (4) select the new dataset tab in the source designer pane and pull your source oracle table data model in the designer of the source. All columns that are relevant to the target card

    (5) make sure that your staging location is set to a relational technology i.e. in this case the target would be an ideal candidate because it is where the ODI will organize the data from source two files and oracle and perform the UNION before loading to the target

    If you want to watch some pretty screenshots showing the steps above, take a look at http://odiexperts.com/11g-oracle-data-integrator-part-611g-union-minus-intersect/

  • Best way to get InDesign files (or the exported pdf file) Acrobat DC?

    Hi all

    I was taken to the top of the interactive forms in Indesign. I like the creation of form-everything is very specific and very accurate. I feel like Adobe is lacking in this regard and with regard to the toolset.

    / But /, Indesign does not support the level of script Acrobat when it comes to creation of interactive form. What I do is, I exported the PDF from Indesign, then by defining it as a background in Acrobat. That worked fine for me up until I created a multipage document.

    It seems that I can not put a background in Acrobat 1:1 with the pdf I created. It still affects each page with the background, be it a page of pdf or page 2 or page 3...

    Someone at - it a good workflow, a way to get the most out of Indeisgn without taking too many steps to change the pdf file in Acrobat? Perhaps with a plug-in?

    Have you tried the replace command pages in Acrobat. Seems it would be exactly what need you.

  • Why do I get different results for the same resolution but different boxes of Windows, Windows 7 and XP

    I use an .exe on two different windows boxes, in Windows 7 and XP.  I put both for resolution 1024 x 768.

    Win 7 (old laptop and Dell desktop computer) I have a large application to watch.  On the WIn XP boxes all fonts to big.  It doesn't make sense for me as all PC's have the same resolution.

    Has anyone go through this before?

    System for XP and Vista/Win7 fonts are different.

    See

    http://forums.NI.com/T5/LabVIEW/elements-have-moved-when-opening-VI-with-F3-patch/m-p/1054817

    http://forums.NI.com/T5/LabVIEW/what-can-affect-the-size-of-a-front-panel-object-between/m-p/1058607...

    http://forums.NI.com/T5/LabVIEW/font-size-on-Windows-7-with-LabVIEW-2009/m-p/1055114/highlight/true#...

    and several other similar topics.

  • What is the best way to get this layout of the chapter?

    I have a document which is now a large flow of pages.

    However, there are "chapters, in this 'book'. A 'chapter' actually starts on the right page. But I want the left page to participate in the design of the spread of the beginning 'chapter '. This means that left before the start page real "chapter" is reserved in control of layout and all "chapter" before that would end on a left page, needs a right-hand page empty inserted, after which the left page of the early-'chapter' spread follows.

    Now, I can do the pages on the left of the start "chapter" start a section and to correct even a page number. That it is positioned on the left side. But when I add pages from the previous section, this means I have to change the page numbers of the beginning of all the sections that follow hand.

    Are there not a better way to do this? Somehow I don't have to worry about the numbering of the pages myself while still getting the page before the "chapter" included in the section of this "chapter"?

    (I write "chapter" because these aren't chpaters Id in an Id book, but a few sections in a single document Id).

    If the previous "chapter ends with a page of pairs (left hand), you add two pages, if it ends on the right add you a..

    Another way to do this automatically is to set an Option to keep on the paragraph style that you use for the first paragraph on the page at beginning of chapter, then it will start the section on the next odd-numbered page.

  • Query to find the sum of the different groups in the same column

    Hello

    I have a table as follows:



    visitors
    ------------------------------------------------------------------------------------------
    months of amt credit CustID
    --------------------------------------------------------------------------------------------
    001 C 2000-Jan-2012

    001D 5000 Feb 2012

    001C 3000 Mar-2012

    001C 3000-Apr-2012

    001D 7000-may-2012



    I have to write a single query to calculate the sum of the credit and the sum of the flow values separately.


    Thank you and best regards,
    SB2011

    Hello

    Select decode (credit,' it, sum (amt), sum (amt)) in the Group of customers to credit;

    Published by: 937440 on 24 February 2013 07:06

  • Different numbers on the same column of a table

    Hello

    I have a table of the city with a column of the population. I want to count the cities which are cities or towns or cities biger...

    cities are with the population up to 100000
    are the cities with the population of 100000 to 1000000
    and cities with a population greater than 1000000...

    I need to write a query with minimum cost optimize...

    any quick help will be highly appreciated...


    Thank you

    Hello
    Try:

    SELECT  SUM(CASE WHEN population <= 100000 THEN 1 ELSE 0 END) town_count,
          SUM(CASE WHEN population BETWEEN 100001 AND 1000000 THEN 1 ELSE 0 END) city_count,
          SUM(CASE WHEN population >= 1000001 THEN 1 ELSE 0 END) big_city_count
      FROM city_table;
    
  • How to exchange the two values in the same column by using the UPDATE?

    Hi all

    I have a table named TEST, and it has a column called A.

    and has values as follows:

    A
    ------
    10
    20
    30
    40
    50

    My question is how to move '10' instead of '20' and '20' instead of '10' in the column? This permutation is only for the first two values (10, 20)

    Note: Must be only in SQL, not in PLSQL.

    Any advice?

    Thanks in advance?

    Update
    test
    the value a = decode(a,10,20,20,10,a);

    Alexander gelin
    http://nimishgarg.blogspot.com/

  • Mulltiple criteria on the same column - please help with query

    Could someone help with this query?

    I have three tables-

    Table: SuperOxMap
    -------------
    ox_id
    ox_pd

    Table: SuperCPDtls
    ------------
    ox_pd
    ox_dtid

    Table: SuperPkDtls
    ------------
    ox_dtid
    ox_pkVal

    Example of SuperPkDtls-
    -------------
    ox_dtid ox_pkVal
    1 T1
    2 T2
    3 T3

    As seen above, SuperOxMap.ox_pd = SuperCPDtls.ox_pd and SuperCPDtls.ox_dtid = SuperPkDtls.ox_dtid.

    I find list of the SuperOxMap.ox_id and the SuperPkDtls.ox_pkVal where pkVal for this ox_id contains T1 and T2, but excludes the T3.

    If I put in my join query IN ("T1", "T2") and! = 'T3', which obviously do not work. I don't know how / if I can use the inner query so that he can give me all the ox_ids where associated pkVal contains T1 and T2 but would not T3 contain.

    You will appreciate all help!
  • Multiple values for the same column in the columns of diffétent in the same row?

    Hi all
    I wonder how you can display different values for the same column in different columns on the same line. For example, using a CASE statement, I can:

    CASE WHEN CODE IN ('1 ', ' 3') THEN COUNT (ID) AS 'Y '.
    CASE WHEN CODE NOT IN ('1 ', am') THEN COUNT (ID) AS "N".

    Yes, that will produce two columns but will produce null values to empty and also two separate registers.


    Any ideas?

    Thank you

    Are you sure that this code works for you?

    Select ID
             ,CASE WHEN MODE_CODE IN ('1', '3') THEN COUNT( No) END as "Fulltime"
             ,CASE WHEN MODE_CODE NOT IN ('1', '3') THEN COUNT( No ) END  as "Other"
    From table
    group by ID
    

    I guess the code above fails because MODE_CODE is not in your group by?

    My suggestion would be to put the CASE in the COUNT:

    Select ID
             ,COUNT(CASE WHEN MODE_CODE IN ('1', '3') THEN No END) as "Fulltime"
             ,COUNT(CASE WHEN MODE_CODE NOT IN ('1', '3') THEN No END)  as "Other"
    From table
    group by ID
    

    CASE expressions return no. when the respective conditions are true and NULL otherwise.
    COUNTY will have non-null values.

  • Select literal values in the same column

    Hello
    like the practice:

    Select 'A', 'B', 'C' for double
    will select these values in their own column on the same line, is there a simple way to select these values in the same column on lines without first their insertion into a table?

    Thank you
    SQL> select 'A' x from dual union
      2  select 'B' x from dual union
      3  select 'C' x from dual ;
    
    X
    -
    A
    B
    C
    

    A bit complicated:

    SQL> select chr(ascii('A')+level-1) x
      2  from dual
      3  connect by level <=3;
    
    X
    -
    A
    B
    C
    

    Other:

    SQL> select regexp_substr('ABC','[[:alpha:]]',1,level) x
      2  from dual
      3  connect by level <= length('ABC');
    
    X
    ---
    A
    B
    C
    

    Max
    http://oracleitalia.WordPress.com

    Published by: Massimo Ruocchio, February 12, 2010 17:55
    added a second

    Published by: Massimo Ruocchio, February 12, 2010 17:58
    Added the third

  • Two guests on the same column

    Hi Experts,

    I'm defining two different guests (and associate them with the two variables of different presentation) on the same column. However, when I view the 2 guests on the same dashboard page, whenever I select a value for the first prompt, the same value is automatically selected for the second line.

    Is this a normal behavior? How to capture the two distinct values?

    Thank you
    Guillaume

    Hi William,.

    I think I forgot something.

    You must do the following steps:

    (1) add the column to the dashboard command prompt.
    (2) in the column "Show" change the option to 'results '.
    (3) in the column "Column" change the formula of the column to a name like «filter 1"»
    (4) this column value to the variable in the presentation, such as FILTER1.
    (5) change the label for the column.
    (6) assign the filter in your report to the presentation FILTER1 variable.

    Repeat step 1 to 6 for the second filter.

    Kind regards
    Stijn

Maybe you are looking for