logo
down
shadow

Categorizing Data with SQL Statement to Import Data


Categorizing Data with SQL Statement to Import Data

By : Atm Markerting Gp
Date : November 18 2020, 01:01 AM
it helps some times This insert would do what you want (your logic would have missed anyone that was 20, so I put them in Group A)
code :
INSERT INTO LEADS (NAME, AGE, AGEGROUP)
SELECT
    NAME
    , AGE
    , CASE 
        WHEN AGE <= 20 THEN 'A'
        WHEN AGE > 20 AND AGE < 40 THEN 'B'
        WHEN AGE >= 40 AND AGE < 60 THEN 'C'
        WHEN AGE >= 60 THEN 'D'
    END AS AGEGROUP         
FROM PEOPLE


Share : facebook icon twitter icon
Categorizing data based on the data's signature

Categorizing data based on the data's signature


By : Jun
Date : March 29 2020, 07:55 AM
I hope this helps . EDIT: This is my original answer, which we will call Case 1, where there is no precedence to the keys
You cannot do it as a sorted integer because that is one dimensional and your data is multi-dimensional. So "nearness" in that sense cannot be established on a line.
Categorizing data from DB2

Categorizing data from DB2


By : jay
Date : March 29 2020, 07:55 AM
I wish this help you The first repeat should contain the column headers, images to identify categoization, computed category value, and second repeat. The datasource for the second repeat is making a new SQL call to pull in your specific fields based off the categorized value from the first repeat. The field values are concatenated together so that they can be parsed for each of my computed fields. My blog will show more detail with screenshots. Screenshot shows categorized values on my XPage that are explained by code sample.
code :
<xp:panel xp:key="facetMiddle">
 <xp:table>
  <xp:tr>
   <xp:td></xp:td>
  </xp:tr>
  <xp:repeat
   var="collRowData"
   value="#{jdbcQuery1}">  //name of XPage datasource
   <xp:tr>
    <xp:td>
     <xp:panel id="mainpanel">
      <xp:image
       id="image1"
       style="height:16.0px;width:16.0px"
       rendered="#{jav`enter code here`ascript:
        context.getSubmittedValue()=='hide' || 
        context.getSubmittedValue()== null;}">
        <xp:this.url><![CDATA[#{javascript:"/.ibmxspres/domino/icons/vwicn096.gif"}]]></xp:this.url>
         <xp:eventHandler
          event="onclick"
          submit="false">
          <xp:this.script><![CDATA[var visibility = 'show';
           XSP.partialRefreshGet("#{id:mainpanel}", {
           params: {'$$xspsubmitvalue': visibility}, 
           onComplete: function () {
           XSP.partialRefreshGet("#{id:secondpanel}", {
           params: {'$$xspsubmitvalue': visibility}});}});]]></xp:this.script>
         </xp:eventHandler>
      </xp:image>
      <xp:image
       id="image2"
       style="height:16.0px;width:16.0px"
       rendered="#{javascript:context.getSubmittedValue()=='show'}">
        <xp:this.url><![CDATA[#{javascript:"/.ibmxspres/domino/icons/vwicn097.gif"}]]></xp:this.url>
         <xp:eventHandler
          event="onclick"
          submit="false">
           <xp:this.script><![CDATA[var visibility = 'hide';
            XSP.partialRefreshGet("#{id:mainpanel}", {
            params: {'$$xspsubmitvalue': visibility}, 
            onComplete: function () {
            XSP.partialRefreshGet("#{id:secondpanel}", {
            params: {'$$xspsubmitvalue': visibility}});}});]]></xp:this.script>
         </xp:eventHandler>
      </xp:image>
      <xp:text
       escape="true"
       id="computedField2"
       style="margin-left:5.0px;font-weight:bold">
        <xp:this.value><![CDATA[#{javascript:if (collRowData[0]) {
          collRowData[0] }
         else {
          '- not categorized -'}}]]>
        </xp:this.value>
      </xp:text>
     </xp:panel>
     <xp:panel id="secondpanel">
      <xp:repeat
       var="character"
       rendered="#{javascript:context.getSubmittedValue()== 'show'}">
       <xp:this.value>
        <![CDATA[#{javascript:
         var sql = "Select MBR_FIRST_NM, MBR_LAST_NM from TECH.TBSCRA_DEMO where MBR_ACCESS_NBR = '" + collRowData[0] + "'"; //single quote is before and after collRowData[0]
         var rs = @JdbcExecuteQuery("db2",sql);
         var fName;
         var lName;
         while(rs.next()) {
         //Get the data from the row using the column name
         fName = rs.getString("MBR_FIRST_NM");
         lName = rs.getString("MBR_LAST_NM");
        }
        return fName + "," + lName}]]></xp:this.value>
       <xp:table>
        <xp:tr>
         <xp:td>
          <xp:text
           escape="true"
           id="firstname">
           <xp:this.value><![CDATA[#{javascript:
           var nm = @Explode(character,",");
            if (character) {
             nm[0] }
            else {
             '- not categorized -'}}]]></xp:this.value>
          </xp:text>
         </xp:td>
        </xp:tr>
       </xp:table>
      </xp:repeat>
     </xp:panel>
    </xp:td>
   </xp:tr>
  </xp:repeat>
 </xp:table>
</xp:panel>
categorizing data in R

categorizing data in R


By : user2043713
Date : March 29 2020, 07:55 AM
wish helps you You should use the %in%-operator instead of the identity--you are comparing against a vector here.
Like so:
code :
test$type <- ifelse(test$bank %in% sob, 1, ifelse(test$bank %in% fob, 2, ifelse(test$bank %in% jov, 3,     4)))

> test
     bank  ROE type
1   bank1 0.73    1
2   bank2 0.94    1
3   bank3 0.62    1
4   bank4 0.57    2
5   bank5 0.31    2
6   bank6 0.53    2
7   bank7 0.39    3
8   bank8 0.01    3
9   bank9 0.16    3
10 bank10 0.51    3
11 bank11 0.84    3
12 bank12 0.18    4
levels(test$type) <- list('sob' = sob,
                          'fob' = fob,
                          'jov' = jov,
                          'other' = 'bank12')
> test
     bank  ROE  type
1   bank1 0.73   sob
2   bank2 0.94   sob
3   bank3 0.62   sob
4   bank4 0.57   fob
5   bank5 0.31   fob
6   bank6 0.53   fob
7   bank7 0.39   jov
8   bank8 0.01   jov
9   bank9 0.16   jov
10 bank10 0.51   jov
11 bank11 0.84   jov
12 bank12 0.18 other
Categorizing Data frame with R

Categorizing Data frame with R


By : Maisa Uusivuori
Date : March 29 2020, 07:55 AM
I hope this helps you . It's easier to do math with columns than with rows. So the first step is to move baseline numbers into their own columns, then use cut to define these groups:
code :
library(dplyr)
library(tidyr)

foo <- data %>%
  filter(t == 0) %>%
  left_join(data %>% 
              filter(t != 0),
             by = "ID") %>%
  mutate(percentchange = (a.y - a.x) / a.x,
         My_Answer = cut(percentchange, breaks = c(-1, -0.3, 0.25, Inf),
                         right = FALSE, include.lowest = TRUE, labels = c("g3","g2","g1")),
         My_Answer = as.character(My_Answer),
         My_Answer = ifelse(percentchange == -1, "g4", My_Answer)) %>%
  select(ID, t = t.y, My_Answer)

foo 
  ID t.x a.x t.y a.y percentchange My_Answer
1  1   0 100   5 105          0.05        g2
2  1   0 100  10 126          0.26        g1
3  1   0 100  20 130          0.30        g1
4  1   0 100  30 150          0.50        g1
5  2   0 100   5  90         -0.10        g2
6  2   0 100  10  76         -0.24        g2
7  2   0 100  20  51         -0.49        g3
8  2   0 100  30  40         -0.60        g3
foo %>%
  filter(t == 10)

  ID  t My_Answer
1  1 10        g1
2  2 10        g2
Categorizing data in Excel

Categorizing data in Excel


By : Jinhong He
Date : March 29 2020, 07:55 AM
wish of those help Assuming your data is in column A (the numbers, 11, 21, 21, 50, 67, and 45), and the "Bin" number is in column B
Where you want 123, 71, 21, you can use do this on a new range, say starting in column E (where you have the 1, 2, 3, etc.)
Related Posts Related Posts :
  • How can I use dataproc to pull data from bigquery that is not in the same project as my dataproc cluster?
  • DMSDK Transactions - Marklogic JAVA API
  • Unison move root with rootalias
  • Why is Crystal .should be producing a spurious error
  • zendframework 3 - identity view helper error
  • SPARQL delete query dotNetRDF does not modify RDF file
  • 403 Forbidden Error. Hosting a website on my PC with WAMP?
  • TimerOne and Serial Libraries
  • o I need to set somehow create_engine put in singleton to be like singleton?
  • how to count instances between a range in libre office calc 4
  • Assign integer values to color in opengl es 2.0
  • circle with conical gradient in android
  • items not showing in mvxlistview
  • java.lang.ClassNotFoundException: org.sonatype.aether.version.InvalidVersionSpecificationException
  • Time complexity (in big-O notation) of the following code?
  • Error: Bad value twitter:domain for attribute name on element meta: Keyword twitter:domain is not registered
  • AHK: Unpress All Pressed Keys
  • Decimal output parameter rounded to integer in EF5.0
  • Error when deploying ear in weblogic 11g
  • autocomplete with extjs :ComboBox with REMOTE query store
  • How to make full background color in skeleton, responsive 960 grid?
  • How to send a variable of type struct in MPI_Send()?
  • I accidentally deleted a picture in my album on FB and it was uploaded years ago and I dont have a copy how can i get it
  • Does setting techOrder for video.js really work?
  • What are XMPP extensions (XEPs), and how do I use them?
  • Interactive alternative to dot?
  • Doctrine 2: how do you use a subquery column (in the SELECT clause)
  • Merging graphs using boost graph
  • Creating Order Item Grid in Magento
  • Can't remap Ctrl+W to the F2 key in autohotkey
  • Property 'throw' does not exist on type 'typeof Observable'
  • Unable to deploy SAPUI5 application with 404 error
  • Xcode 10 build fail rm permission denied in /bin/sh/
  • Handling quorum writies fail on Cassandra
  • How to finalize log file just after time is over when using logback SizeAndTimeBasedFNATP?
  • Write custom widget with GTK3
  • How to remove UINavigationBar inner shadow in iOS 7?
  • Wordpress dynamic widget by location?
  • XDocument replace all node value with lower case
  • Invalid tagdir attribute while web-fragment is used
  • Set default font/text size in RTF Control
  • what video formats supported by chromecast device (mp4,flv,m3u8,flv,avi)?
  • sbcl - how to muffle "undefined variable" warning?
  • Get an eventbrite event ID
  • Obtain date without timestamp in DB2
  • Cron job to SFTP files in a directory
  • Draw two head arrows in fabric.js
  • YOLO darknet vs darkflow
  • Parse custom rss tags using Rome API
  • Creating text editor like EDIT on Command Prompt using FreePascal
  • Subplot hides xlabel
  • NServiceBus long running process that timesout
  • Qt4 - How to add a row in a QTableWidget when sorting is enable?
  • Cancel command in Grunt that hasn't been launched
  • Canvas globalCompositeOperation is not working correctly
  • HTML.Kendo().Dropdownlist set default item
  • vagrant up failed, /dev/vboxnetctl: no such file or directory
  • How to use jssor carousel to build client carousal
  • Theory what is meant by validating security concerns for these user groups
  • How to build correct SPARQL Query
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org