Help in writing SQl Statment

Hi all,
I have a table which contain project details those are the coulmns:
Project_number (PK)
Submit Date
Project_title
Project_milestones
I want to retrieve how many number of project in each mounth per year
Output Example:
Date Number of projects
FEB 2008 *6*
March 2008 *5*
FEB 2009 *4*
March 2009 *7*
And so on, I tryed to write an sql statment to retrieve the desired results but I couldn't.
If any one has any idea in retrieving such result please assist me how to write this sql statment.

Hi,
If submit_date is a DATE, then TRUNC (submit_date, 'MM') is the beginning of the month that countains it.
So you can say:
SELECT    TRUNC (submit_date, 'MM')   AS month
,         COUNT (*)                   AS cnt
FROM      project_table
GROUP BY  TRUNC (submit_date, 'MM');Of course, you can add TO_CHAR to the first line to format the date however you like.

Similar Messages

  • Help in writing SQL query

    Hi evrybody,
    I have a requirement which seems very wierd to me, I m unable to clue it also. Please help me in writing the same.
    I have a column in a table which contains the data with spaces and everythng same as below:
    SUBSCRIBER LINE TEST
    VERSION 2
    DEV SNB MP FCODE
    LIBA-13 4222430012 11 3
    FOREIGN VOLTAGE TESTS
    DC AC
    FVAE FVBE FVAB FVAE FVBE FVAB
    LACC LACC 7.4 0.1 0.1 0.1
    0.0 0.0 PASS PASS PASS PASS
    PASS PASS
    INSULATION RESISTANCE TESTS
    IRAE IRBE IRABA IRBBA IRAB
    LACC LACC LACC LACC 8113K
    10000K >10000K >10000K >10000K PASSPASS PASS PASS PASS
    CAPACITANCE MEASUREMENTS
    CAE CBE CAB BRK
    LACC LACC 4428 NO
    68 72
    NT LOOPBACK TEST
    PASS
    NT DC SIGNATURE TEST
    V-HIGH V-LOW
    83.920K LACC
    PASS >10000K
    PASS
    NT CONNECTED
    INV
    CIRCUIT TEST RESULT
    FAIL
    I need to get the o/p as:
    FVAELACC=0.0 FVBELACC=0.0 FVAB=7.4 FVAE=0.1 FVBE=0.1 FVAB=0.1
    CAELACC=68 CBELACC=72 CAB=4428
    NT CONNECTED=INV..
    Thanks in advance.

    Evrybody thanks for advices. My Question is little unclear but the requirement is that itself.. Anyways I got the O/p finally.
    Mr. Shahzad ,if any of the questions makes u feel like wasting ur technical time, jus donot read it.. The people who can undertsand the problem, they can answer to the post. If the requirement is like that, none of us are helpless.

  • Need help in writing SQL query

    Hi,
    I have a rquirement where I need to convert columns into records.
    Table1:
    (note: I have around 150 columns i.e period1 to period150)
    unit startdate Period1 period2 period3 period4 period5
    A 1/1/2011 100 200 300 400 500
    Now I need data in below format
    UNIT startdate period
    A 1/1/2011 100
    A 1/1/2011 200
    A 1/1/2011 300
    A 1/1/2011 500
    Please suggest me...
    Thanks.

    With UNPIVOT you can "name" each of your rows using as.
    One trick is to "name" the rows to a number - then you can add that number of weeks to your start date - like this:
    with t as (
       select 'A' unit, DATE '2011-01-01' startdate, 100 period1, 200 period2 ,300 period3, 400 period4 ,500 period5 from dual
    select
    unit,
    startdate + numtodsinterval(week*7,'day') startdate,
    qty
    from t
    unpivot(
       qty for week in (
          period1 as 0,
          period2 as 1,
          period3 as 2,
          period4 as 3,
          period5 as 4
    ;Theoretically the above should work - but somehow I get a NULL date on my 11.1 instance? And I don't have another version to test with, alas.
    But try it and see if it works on your instance ;-)

  • SQL Statment Help

    hiya
    i need help about SQL statment i want get all employee Data if i know the emp_no get specify recored if emp_no = null get all Data
    select * from employe where emp_no=123 if emp_no=null get all records
    thx

    Hi,
    Welcome to the forum!
    Ttushar's solution is what you requested.
    If empno can not be NULL, then you can also modify it like this:
    SELECT  *
    FROM     employee
    WHERE     emp_no = NVL (:v_emp_no, emp_no);

  • Need help in SQl statment

    this SQL statment work in oracle database :
    SELECT TO_DATE('20080627','YYYYMMDD') - TO_DATE('20080526','YYYYMMDD') FROM dual
    But didn'twork on Timesten Database and this error is appear
    2789: An interval data type must be specified for a datetime arithmetic result
    The command failed.

    SELECT extract (day from TO_DATE('20080627','YYYYMMDD') - TO_DATE('20080626','YYYYMMDD')) FROM dual;
    See
    http://download.oracle.com/otn_hosted_doc/timesten/703/TimesTenDocumentation/wwhelp/wwhimpl/js/html/wwhelp.htm?&accessible=true
    for details.

  • Help needed for SQL query

    hello ,
    I am a beginner in terms of writing sql queries. I hope some body can help me out.
    I have two tables
    mysql> desc user_group_t;
    ---------------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    ---------------------------------------------------+
    | userAccountId | char(8) | | PRI | | |
    | groupId | char(8) | | PRI | | |
    ---------------------------------------------------+
    2 rows in set (0.00 sec)
    mysql> desc group_t;
    ---------------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    ---------------------------------------------------+
    | id | char(8) | | PRI | | |
    | name | char(50) | YES | | NULL | |
    | email | char(100) | YES | | NULL | |
    | description | char(254) | YES | | NULL | |
    | parentId | char(8) | YES | | NULL | |
    | creatorId | char(8) | YES | | NULL | |
    | createDate | char(20) | YES | | NULL | |
    | updateDate | char(20) | YES | | NULL | |
    | updatorId | char(8) | YES | | NULL | |
    ---------------------------------------------------+
    9 rows in set (0.00 sec)
    what I want is list of all groups with id,name and #of members(which is the # of rows in the user_group_t for any given id). Importantly I need the groups with 0 members also to be listed. In short my output should contain exactly the same number of rows as in group_t table with an additional column indicating # of members for that group.
    Any help would be greatly appreciated.
    Thanks in Advance.
    -Vasanth

    Thanks Donald,
    Actually I figured it out, with the following query:
    select id,name,sum(if(groupid is not null,1,0)) as members from group_t left join user_group_t on id=groupid group by id;
    I tried your solution, but mysql says there is an error at '+' . Anyway I modified your solution to the one below and it worked.
    select a.id, a.name, count(b.groupid) from group_t a left join user_group_t b on a.id=b.groupid group by a.id, a.name;
    I tried that before but then I used Count(*) instead of count on groupid. Your solution is elagant and I will go with yours.
    Thanks again.
    Vasanth

  • Need Help in writing a UDF

    Hi,
    Please help in writing a UDF for these fields in mapping, which I need for the object Iu2019m doing currently.
    The fields are like this:
    1)         batch_no = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/5000)+1",
    2)         lot_id = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/500)+1",
    3)        How to use JDBC connection factory class in the UDF.
    Some logic I can provide which I know i.e. Power (2, 28) means 2 to the power of 28 (2 multiplied 28 times), Trunc means truncate, X_TXN_SAP_Parts is a database table.The Target fields are Batch_no, lot_id & Objid.Actually, objid is mapped initially to a source field i.e. Object ID and in this function it is only being used for the calculation of the batch_no.
    Thanks in Advance,
    Sreedhar.

    Hi,
    Following with my query I've tried to use this code but still I'm unable to execute the mapping.
    import java.util.*;
    import com.sap.aii.mapping.lookup.*;
    import com.sap.aii.mapping.lookup.*;
    DataBaseAccessor accessor = null;
    DataBaseResult JDBCOutPayload = null;
    String BusinessSystem="clarify_dev_bizsys";
    //give your business system having channel name
    String CommunicationChannel="JDBC_TO_CDEV";
    //give your channel name
    String InputPayload= " select X_TXN_PRE_SITE_XFACE.nextval from dual;";
    //give your sql query
    try {
    Channel channel =
    LookupService.getChannel(BusinessSystem,CommunicationChannel);
    accessor = LookupService.getDataBaseAccessor(channel);     
    DataBaseResult resultSet = accessor.execute(InputPayload);
         for(Iterator rows = resultSet.getRows();rows.hasNext();){  
         Map rowMap = (Map)rows.next();
         Object cValue = rowMap.get("batchno");
    //field name of field required , as in database
          catch (Exception e) {}
          finally {
                  if (accessor != null)
                  accessor.close();
           result.addValue((String)cValue);
    --> I don't know what are the parameters to be used and how to be used in the UDF because this is the first time I'm writing a UDF.
    --> The problem in using this query is that both OBJID & BatchNo. are on the target side and the value for the OBJID is retrieved by a SELECT query from the database.
    Kindly help me how to resolve this query of mine.
    Thanks in Advance.
    Sreedhar.

  • Help in writing  query few schema objects  from another schema.

    Hi Gurus,
    Could some one help in writing an sql which will give list of all the object of a schema "genp" visible in another schema "genp_v" and "gen_con" there is an dblink and few grants on those schemas .
    i dont have the password of any of those users i have connected as sys and i can not change the password of any of those users..
    Any help on this is highly apprciated.
    Thanks in advance .

    could you please update me for all the objects apart from just the tables .
    thank you so much .. it was just out of my head at that moment .
    cheers

  • How to access currently executing SQL statment?

    Hello -
    I have a C language external procedure that is called from an INSERT / UPDATE / DELETE trigger.
    Is there a way (using OCI, or elsewhere) to get a string containing the SQL statment that fired the trigger?
    Thanks a bunch for your help!
    -js

    http://databasejournal.com/features/oracle/article.php/3373701
    The second page has more details (there is also a part II to this article if you are interested).

  • Help with writing and retrieving data from a table field with type "LCHR"

    Hi Experts,
    I need help with writing and reading data from a database table field which has a type of "LCHR". I have given an example of the original code but don't know what to change it to in order to fix it and still read in the original data that's stored in the LCHR field.
    Basically we have two Function modules, one that saves list data to a database table and one that reads in this data. Both Function modules have an identicle table which has an array of fields from type INT4, CHAR, and type P. The INT4 field is the first one.
    Incidentally this worked in the 4.7 non-unicode system but is now dumping in the new ECC6 Unicode system.
    Thanks in advance,
    C
    SAVING THE LIST DATA TO DB
    DATA: L_WA(800).
    LOOP AT T_TAB into L_WA.
    ZDBTAB-DATALEN = STRLEN( L_WA ).
    MOVE: L_WA to ZDBTAB-RAWDATA.
    ZDBTAB-LINENUM = SY-TABIX.
    INSERT ZDBTAB.
    READING THE DATA FROM DB
    DATA: BEGIN OF T_DATA,
                 SEQNR type ZDBTAB-LINENUM,
                 DATA type ZDBTAB-RAWDATA,
               END OF T_TAB.
    Select the data.
    SELECT linenum rawdata from ZDBTAB into table T_DATA
         WHERE repid = w_repname
         AND rundate = w_rundate
         ORDER BY linenum.
    Populate calling Internal Table.
    LOOP AT T-DATA.
    APPEND T_DATA to T_TAB.
    ENDLOOP.

    Hi Anuj,
    The unicode flag is active.
    When I run our report and then to try and save the list data a dump is happening at the following point
    LOOP AT T_TAB into L_WA.
    As I say, T_TAB consists of different fields and field types whereas L_WA is CHAR 800. The dump mentions UC_OBJECTS_NOT_CONVERTIBLE
    When I try to load a saved list the dump is happening at the following point
    APPEND T_DATA-RAWDATA to T_TAB.
    T_DATA-RAWDATA is type LCHR and T_TAB consists of different fields and field types.
    In both examples the dumps mention UC_OBJECTS_NOT_CONVERTIBLE
    Regards
    C

  • Need help in writing data from JSP to excel

    Hi ,
    I need help in writing the data from JSP to excel.I somehow able to retrieve the data into excel but unable to get the required format.
    For eg: The amount should be displayed in 0.00 format .when i am exporting it to excel it is displaying as 0 :( .
    I am using the following code in JSP.
    "out.print(amt + '\t');"
    Would like to know if there is any otherway where in i can get my requirement.
    Thanks
    Tom

    Hi,
    Try using format part of the JSTL tag libs.
    Syntax :
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
    <fmt:formatNumber value="40" pattern="$#,##0.00"/>
    I need help in writing the data from JSP to excel.I
    somehow able to retrieve the data into excelHow do u convert the jsp to excel?
    One way to convert the jsp page to excel, is to render it as an excel appl instead of html. Set the content type of the response to application/ms-excel.
    response.setContentType("application/ms-excel")Hope this Helps....

  • Help Needed in SQL QPAC

    Hi there,
    I need some help regarding the SQL QPAC which is a built in QPAC in Adobe Livecycle Workflow. The SQL QPAC takes MYSQL as the default database. Suppose if we need to connect to the SQL Server or any other database, what is the procedure to do that.
    Suraj

    Hi Suraj
    You need to deploy a second copy of the SQL QPAC, and point it at a different datasource. The datasource is defined as a deployment parameter (it will prompt you when you deploy the new version of the qpac).
    You will also need to define the datasource in your application server. This is done in different ways for different application servers - for details, please see: standards_based_qpacs.pdf (part of the Workflow SDK), page 12, "Creating a JNDI datasource".
    Alternately, you can try out our SQLPlus QPAC. This allows you to directly specify connection url, driver, username and password. The SQLPlus QPAC does a lot of other things that the regular SQL QPAC doesn't do, such as handling multiple rows, testing your query, and outputting the data in a variety of ways.
    Details at: http://www.avoka.com/avoka/qpac_library.shtml
    Howard

  • Help in writing a query!

    Dear All,
    My database is 11gR2 on Linux.
    I am struck in writing a difficult query, need help from your guys.
    I have a table, an application is controlling the columns of this table. Columns are added by the application.
    This is the structure of the table:
    create table imran_test(
    2 username varchar2(100),
    3 layer1 number(1),
    4 layer2 number(2),
    5 layer3 number(2));
    -- where layer1, layer2, layer3.... are increased up to layer 22 and could be increased more...
    Now each username will have 1 in any one of the layer, and all other layers will have 0
    Like if I consider the above table this could be the sample data:
    imran 1 0 0
    hafeez 0 1 0
    james 0 0 1
    Now the result my query should return is:
    select username, <column name where value is 1> and value of it, as per sample data, this should be return by the query:
    imran layer1 1
    hafeez layer2 1
    james layer 3 1
    Note: Please remember the columns are not fixed, they are added/altered by application.
    Regards,
    Imran

    The table design is incorrect as it is not in 3NF and has a repeating group
    You should correct the 'design' first or turn the layer... columns in a VARRAY.
    Also my feeling is you should change your subject line 'Help in writing a query!' in 'Write my query' as that is what you actually ask, and leave out the exclamation mark.
    Basically you dump everything in this forum, and being a bit less demanding might suit you better.
    Also you still act rude by not marking your questions as answered.
    Change that
    Sybrand Bakker
    Senior Oracle DBA
    Edited by: sybrand_b on 1-apr-2012 12:09

  • Help with writing a formula

    Hi all,
    I am creating a report, and need help with writing a formula...
    I am creating a report that shows how many visits/touches our reps have made to various grade accounts. It is broken down by calendar week, and I currently have a weekly "goal" number set that the reps have to meet. That "goal" number increases each week to keep a running total. (example: week 1: 7, week 2: 14, week 3: 21)
    I have created some different formulas and one is this:
    SUM("Activity Metrics"."# of Activities" BY Date."Calendar Week")
    What this shows me is how many "visits" there are per calendar week to customers, however it show me the total for all reps per week.
    What I need is that total to show, but totaled for each rep individually.
    What I was trying is this:
    SUM("Activity Metrics"."# of Activities" BY Date."Calendar Week") BY Employee."Employee Name"
    But...I keep getting an error.
    Any suggestions?
    I have the reporting book by Lairson, and have been referring to it...but my brain at this point is fried.
    Thanks in advance for any help...(please forgive...I am new to OnDemand, and I am sure this is easy)

    Thanks for helping!
    I created this formula as a column: SUM ("Activity Metrics"."# of Activities" BY Date."Calendar Week"), it is called "total number of visits per week" and it shows the totaled number of visits that all the reps have done per calendar week. For example: Week 1: 10 visits, Week 2: 37 visits, Week 3: 20 visits.
    What I would like to do is take that column and break it down further, to show instead how many visits per week by sales rep there have been
    So what I was trying was to take the "total number of visits per week" (SUM ("Activity Metrics"."# of Activities" BY Date."Calendar Week")) and use "Activity Owner" (Employee."Employee Name") to break it down further.
    What I need to use is the total number of visits each rep has per calendar week.
    I think I am getting the error because you can't use "BY" twice in a formula?

  • Help with writing a batch file

    Hi :
    does anyone know anyplace online that I can get help in writing batch files?? I have never worked much with batch files before....
    any help is greatly appreciated
    thnx

    I suppose, since you're in a Java forum, you need batch files to load java applications.
    If you use windows :
    go to ms console (start/run/"cmd")
    type edit mybatch.bat
    write your command to load a java application, something like
    java myclass.class
    save and exit.
    Be sure the bat file and the class are in the same folder.
    And make certain you've set the classpath, and path variables correctly.
    If this was what you needed and you need more help just ask.
    (In this case it could be better to make executable jars)
    If you wanted to know about linux batches, it works pretty the same way.

Maybe you are looking for

  • HT4910 My Contacts are no longer available in Outlook 2007 after an iCloud sync.

    My contacts have been syncing between Outlook 2007 and iCloud just fine for over a month. Today the contacts are gone from Outlook, but I still see them on my iPhone 5s and on iCloud.com. What happened, how do I prevent it from happening again, and h

  • Column total_retail bad value

    Hi All, I have a problem with the values on columns TOTAL_RETAIL and UNITS from table IF_TRAN_DATA. When I consult using PL/SQL or SqlDeveloper, this is the results: select total_retail, units from rms12.if_tran_data where rownum <= 5; -0,0101     10

  • Euphonix MC MIX and Logic 9.0.x = no tracks volume values display

    Hi, Did anybody noticed that, since introduction of Logic 9.0.1 update, the track volume values aren't showed in the MC MIX display anymore? Euphonix support says that they are aware of the problem and are working close to Apple to resolve the issue,

  • Plugin for equalizer controls on each channel

    Hello everyone, I'd like to be able to equalize each channel (the left and the right channel) of my computer's output audio separately. My reasons for doing this are somewhat complicated, but I am looking for some sort of plugin either for iTunes or

  • Ipad needs activation.

    My Ipad still wont activate after restoring to factory default, I've already downloaded the necessary updates and tried installing them. I tried using cables to connect to itunes, but still wont work. Been getting this message everytime: "Sorry we re