SQL that are based on the values of the corresponding fields.

Hi my name is Hawk.

I'm new to the Forum, and I wanted to just introduce myself and say hi.

I have a daunting task to summarize values and filling in a spreadsheet with columns. I have 600 lines to go, and I was wondering if

someone knows a way in sql to sum (a body of numbers) based on the existence of a value being the same on another field of varchar2.

For example, here is an example of the data table that I have.

CREATE TABLE EXAMPLE

("FIRSTNAME", VARCHAR2 (20 BYTE),

VARCHAR2 (20 BYTE) "LASTNAME."

NUMBER OF "SUMVALUE."

NUMBER OF "ROW_ID".

);

Insert into SAMPLE (FIRSTNAME, LASTNAME, SUMVALUE, ROW_ID) values ('Charlie', 'chocolate factory', 100, 1);

Insert into SAMPLE values (FIRSTNAME, LASTNAME, SUMVALUE, ROW_ID) ('Johnny', 'Desire', 200, 2);

Insert into SAMPLE (FIRSTNAME, LASTNAME, SUMVALUE, ROW_ID) values ('P', 'Frankenstein', 300, 3);

Insert into SAMPLE (FIRSTNAME, LASTNAME, SUMVALUE, ROW_ID) values ("Charlie", "chocolate factory", 400, 4);

Insert into SAMPLE (FIRSTNAME, LASTNAME, SUMVALUE, ROW_ID) values ("Charlie", "chocolate factory", 500, 5);

and Yes, I have 600 lines having to ask and things to the top score on manually, it's just bs data...

So what I do is the following.

Write some sql that will total the number field (sumvalue) based on data with firstname = lastname = chocolate factory and Charlie.

It seems so simple, but still I can not understand how do.

Is that what I'm trying to make sense?  Also, I hope this is the right place to post this. I looked on this before I posted to make sure.

Hawk.

Hi, Hawk,

Here's one way:

SELECT SUM (sumvalue) AS total_sumvalue

SAMPLE

WHERE firstname = 'Charlie '.

AND lastname = 'chocolate factory '.

;

Welcome to the forum!

There are those who use the forum for years and have not yet learned to post CREATES instructions TABLE and INSERT for their sample data, as you did.  Keep up the good work!

You should also post the exact results you want from the data provided.  For example

TOTAL_SUMVALUE

--------------

1000

(this is what produces the query I posted).  As you can see, without that David and I came with 2 different interpretations of what you want and maybe aren't exactly what you need.

Tags: Database

Similar Questions

  • Looping through the names of columns that are based on a value of the variable

    I have an ArrayCollection collection with a series of columns named price1, price2... through price10

    I try through these columns based on a value of the loop variable, but may not understand the syntax:

    for (var column: int = 1; column < 11; column ++) {}
    testPrice = myGrid.selectedItem.price (column); <-this does not work
    }

    Try testPrice = myGrid.selectedItem ["price" + column];

    Don't forget to test this selectedItem is not null before you try to set the values.

    TS

  • The list of all names of virtual machines that are attached to the computer with script group

    I need a script that would list all the virtual machines names that are attached to the Machine group as the bellows screenshot:

    vcm.jpg


    Ce can be in any language I just need to get this information.

    I tried to Watch in database and found vm names of in table [ecm_dat_machines] and Group of/ids in names of table [ecm_sysdat_machine_groups] but I don't find table that would be assign vm to the Group.

    I serait appreciate any help or clue as I already spent a lot of time on this task.

    Attached file of import/export includes a view created for the SQL below, as well as a SQL report that uses this perspective to the computers by group in the VCM UI.

    Note that the functions used in the join of the query criteria are there to ensure that only valid/active/license machines are displayed, these date data and time are adjusted to the time zone of the user, and that the users do not see that their role does not have access to groups of computers.

    SELECT

    m.machine_name,

    mg.machine_group_name,

    mg.machine_group_desc,

    DATEADD (mi, utc.utc_offset, m.date_last_contact) as date_last_contact

    OF dbo.ecm_dat_machine_group_machines_xref mgx

    JOIN dbo.ecm_dat_machines m

    ON mgx.machine_id = m.machine_id

    Join dbo.ecm_dat_machine_groups mg

    ON mgx.machine_group_id = mg.machine_group_id

    JOIN dbo.ecm_dat_roles_machine_group_xref rmx

    ON mgx.machine_group_id = rmx.machine_group_id

    AND rmx.role_id = dbo.role_current)

    JOIN dbo.ecm_fn_machines_valid_t (vm)

    ON mgx.machine_id = vm.machine_id

    JOIN dbo.ecm_user_utc_offset (utc)

    1 = 1

  • Why are on the first web page are buttons and following pages Don t-shaped? All Pages are based on the same Masterpage.

    Hello

    I ve a problem with Muse.

    Why are on the first web page are buttons and following pages Don t-shaped? All Pages are based on the same Masterpage.

    Any ideas?

    Stefan

    Hello Stefan,

    Could you please share your with us .muse file to study? Please send it to [email protected]. If your file is larger than 20 MB, you can use something like Adobe SendNow SendThisFile or Dropbox. Don't forget to mention the link to this forum thread in your email so that we can identify the file.

  • 'Burned' fingers index to use MacBook Pro trackpad: my both hands, index fingers. which are based on the computer next to the trackpad or are used on the trackboard are painful, feel like they were burnt, and I can barely move them.  Yes, I did

    My both hands, index fingers. which are based on the computer next to the trackpad or are used on the trackboard are painful, feel like they were burnt, and I can barely move them.  I do not have this problem before, I bought my new Mac - specifications below: it hurts and I don't have a problem with my windows, iPad or Samsung Galaxy equipment operating systems computers.

    It feels like radiation leaking through the computer case.  Is the radiation involved in the chips?

    MacBook Pro

    Model identifier: MacBookPro11, 4

    Processor name: Intel Core i7

    Processor speed: 2.2 GHz

    Number of processors: 1

    Total number of Cores: 4

    (By heart) L2 Cache: 256 KB

    L3 Cache: 6 MB

    Memory: 16 GB

    Boot ROM version: MBP114.0172.B06

    Version of the SCM (System): 2.29f24

    Are you use while plugged in, I feel a buzzing in my 13-inch rMBP (12.1)

  • I would like to have at least 1 of my toolbars that are displayed at the bottom of my browser open screen. How can I move a toolbar from the top to the bottom of the page?

    I would like to have at least one of my toolbars that are displayed at the BOTTOM of my browser open screen. How can I move a toolbar from the top to the bottom of the page? I don't want to do this by using an extension, and when I read about the extension, I really have not seen how it would move the toolbar to the top-down any browser page open.
    Thanks in advance for the supply, the answer and the procedure to get this accomplished.

    You can't drag an entire toolbar to the bottom of the window. The Bar of the Addon is a "toolbar", drag whatever you want from the Palette to customize or a toolbar up to the bar of the Addon.

  • Problems loading a file in SkyDrive: "sorry, SkyDrive can't download files. Please download the files that are contained in the folder instead.

    Whenever I try to add a "xlsx" to "SkyDrive" document I get the following message:

    Sorry, SkyDrive can't download files. Please download the files that are contained in the folder instead. Neither I am able to drag and drop files in skydrive folder!

    I even tried as well to load it from the Office & do slip from the "Desktop" to the "SkyDrive" - but not of joy!

    Assistance would be greatly appreciated

    > Sorry, that SkyDrive impossible to download files. Please download the files that are contained in the folder instead.

    He tells you to OPEN the file, download the files on skydrive. BUR, NOT the FOLDER itself.

    You can download several files at the same time. How many? I'm not sure. I do not have more than 2 files both myself.

    SkyDrive limited maximum 50 MB each download.

  • -L' stop six options that are next to the lock button in the task in the task bar disappear from my computer.

    -The six closure options that are next to the lock button in the taskbar disappear from the my computer. When I click on the arrow next to the lock button, my only computer log screen and lock up instead of six normally closed options i.e (change user, locking, lock, re - start, suspend and logoff.)
    -The first step, I took is to check for assistance and support in my system, and I could not find a guide on how to restore six back closure options.
    -There is not any notification of any errors.
    -My product/name of Microsoft's Windows vista Home Basic edition. Model: Compaq presario CQ60 Notebook PC
    All I want is no details to restore my missing shutdown options. Or if you can restore it for me online.

    Hello

    • What were the changes made before the problem occurred?

    You can view these methods:

    Method 1:

    I suggest you to start your computer in safe mode with network and check.

    http://Windows.Microsoft.com/en-us/Windows-Vista/start-your-computer-in-safe-mode

    Method 2:

    Try the SFC scan on the computer in mode noraml.

    SFC/scannow is a very useful command that you can use in any version of Windows. When the SFC (System File Checker) command is used with the/scannow switch, the tool analyzes all the important files of Windows on your computer and replace if necessary.

    Missing and the corruption of the operating system (like many DLLs) files are probably the main cause of the major problems of Windows. In view of this, plus the fact that the SFC/scannow is completely automatic and very easy to use, the tool should be usually one of your top not troubleshooting.

    Reference:

    How to use the System File Checker tool to fix the system files missing or corrupted on Windows Vista or Windows 7
    http://support.Microsoft.com/kb/929833

    Method 3:

    Run a full scan with your antivirus software and removal of malware/spyware.

    http://www.Microsoft.com/security/PC-security/MSE.aspx

    Malware:

    http://answers.Microsoft.com/en-us/Windows/Forum/windows_vista-security/how-to-get-rid-of-malware/ba80504b-61f1-4D71-960f-b561798b7b42

    Method 4:

    You could also try to perform a system restore.

    http://Windows.Microsoft.com/en-us/Windows-Vista/what-is-system-restore

  • Will I lose my music downloads that are located in the "MY DOWNLOADS" folder "IF" I remove them, once they are transferred to my iTunes account?

    Will I lose my music downloads that are located in the "MY DOWNLOADS" folder "IF" I remove them, once they are transferred to my iTunes account?

    Hello JMarione,

    Thank you for your message.  Because it's really a question of iTunes I refer you to http://www.apple.com/au/support/itunes/.  Support you should get it will ensure that all your media will be transferred correctly.  This is a forum for Vista, and many people have different one from the other configurations.  A good answer for a single person on this forum could still lose you some of your files, because the installation program may be different.  Good luck.

    See you soon

  • Public Static T3600 noise coming from headphones that are connected to the headset before decision-making.

    I have problem with my T3600 when used before headphone jack. Noise coming from headphones that are connected to the telephone jack of heat before, however, I tried to connect with rear headphone jack is good. If I put the system in standby mode, when I restart the audio does not work, but the noise electric only in my helmet!

    Hoping to see an improvement soon.

    Hello

    I did the steps you recommended, but my computer is still such a situation.
    I'm using BIOS version A14, audio Realtek ALC269 and Driver for High Definition Audio Driver Version 6.0.1.5890, A06.
    Drivers for Service NOTE from the ADMINtag: maintain the label removed by privacy policy >
    Please help me. Thank you

  • View the programs that are running on the remote computer.

    How use remote desktop to view the programs that are running on the remote computer. I connect to the pc remotely is used to monitor a communication system for the alarms. The alarm Viewer application runs as a service. When I connect locally to the computer, I can see the application and view the status of the alarm system. When I connect via remote desktop, I can't. I don't see that the application is running in the services list.

    Do you mean the Task Manager?

    If so, try using change sequence to bring up the Task Manager while in the session remote desktop active...

    http://Windows.Microsoft.com/en-us/Windows7/keyboard-shortcuts

    You might also find something in the PsTools collection...

    http://TechNet.Microsoft.com/en-us/Sysinternals/bb896649

  • For a given file, how to add and change file properties on the Details tab, for properties that are not in the properties list?

    Now, I am aware of the modification of the properties of the file is simple in Windows 7 Explorer. Select a file, 'Properties', then tab "Details".  Some are not editable, and that's understandable.  Click on next to any area classified as year, Genre, Publisher, etc. and the apply.  No problems so far.

    Then of course in Explorer, when you right click on a column header, you get several choices of column beyond the usual that is displayed by default; Date, the Type, size, etc.  But, there is an option "More...", which has up to now, MUCH more useful properties to choose from, such as the model project, Department, job statusand so on.

    It's fantastic!

    But when you look into the details of any given file, none of these additional properties even are listed to be edited.  Why offer to view these details, if you don't change them, or add them to different files?  I must be missing something.  I do not need to add my own custom details, this additional list has a choice, that I need; If only I could edit the files to get this info.

    How to add and change these properties to files?  Word, Excel, MP4, AVI, JPG; I would add these properties, so I can set directly in the Solution Explorer, as you would by name or Type.

    Any help would be greatly appreciated!

    My experience is that most of these 'extra fields' no existence not as fields in the directory (folder) itself.  On the contrary, these fields exist in the target file itself. Each file type has its own format and established file except for the types of files that belong to Microsoft, Microsoft cannot control or arbitrarily change the format of a particular file type.

    For example, a ".jpg" file  The format of this file type allows a large number of areas such as comments, Tags, date taken, opening, device manufacturer and so on.  If you go into the properties on a .jpg file, you will see a lot of them and will be able to change.  After changing any of these fields, you will find that the file itself has been changed to contain this information (as can be verified by the parity of the file and to come check upward with a different checksum).  If you display one of these fields in Explorer and 10000 ".jpg" files in this folder, then Explorer must open each of these 10000 files to extract the data in the corresponding fields, you have chosen to display.  May take some time.

    Compare that to the same picture saved to a file ".bmp".  The ".bmp" format has no provisions for any of these fields, so you will not be able to view, save, edit, or sort by them.  If the editable fields are directly related to the type of file that is displayed.

    Microsoft has apparently interviewed a lot of file types and made a compilation of the editable fields in each type of file and the Union of the selected fields in which can be displayed and modified.   That's apparently what you see in the option «More...» ».   So, in summary, the file type determines which fields are available for editing and posting.

    HTH,

    JW

  • How to find computers that are not on the domain in an Active Directory forest.

    Hello

    I'm looking for a tool that can scan a subnet and give me the list of computers that are not on the field, but connected to the network. My company has recently spent a lot of users of the task force to the area, but there is a population of users who are unwilling to join the domain and still using the local administrator to log on to the computer.

    These computers do not meet the domain policies applied and causing many problems with the network and other systems on the field.

    Help, please.

    concerning

    Syed M. Uzair

    This issue is beyond the scope of this site and must be placed on Technet or MSDN

    http://social.msdn.Microsoft.com/forums/en-us/home

  • How can I get a list of jobs that are planned for the days of the future

    How can I get a list of jobs that are planned for the days of the future?

    In a previous article, I found a query that lists the scheduled tasks that are already running. Can I get a similar request for the future days which is compiled?

    Hi sreedevir,

    SELECT jobmst.jobmst_prntname, jobmst.jobmst_name, jobrun.*

    FROM jobrun JOIN jobmst ON jobmst.jobmst_id = jobrun.jobmst_id -joining tables jobmst and jobrun

    WHERE jobrun_proddt > = dateadd (dd, 1, datediff (dd, getdate())) 0, -future dates

    AND jobmst.jobmst_type = 2 -given jobs (and not groups)

    ORDER BY 1, 2 -Sort by name of the parent, then by task name

    Feel free to make any changes to your reporting needs

    ARO

    The Derrick

  • How can I see the list of programs that are allowed through the firewall?

    How can I see the list of programs that are allowed through the firewall?  I can't find the list.

    Open Windows Firewall and select 'allow a program or feature through Windows Firewall. You can then view or modify programs all allowed.

    Jim

Maybe you are looking for