How to do this with one query?

here is the basic query
<cfquery name="getCenturies"
datasource="#application.dsn#">
SELECT riderId, rideDistance, rideDate
FROM mileageLog
WHERE rideDistance > 99
</cfquery>
and my results would be something like
Kevin 114
Chris 103
Kevin 100
Don 102
Kevin 106
Now how can I get the count for each person
Kevin 3
Chris 1
Don 1

jkgiven wrote:
> I appreciate your help
>
> taking a look at your suggestion, the >99 part needs
to refer to the
> rideDistance column (the 114, 103, 100, 102, 106) thus
the greater than 99
> amounts. And how would I refer to each rider count total
(Kevin 3, Chris 1, Don
> 1)
>
> I reworked the quety to this... but still no go
> SELECT riderId, count(riderId) AS riderCount,
rideDistance
> FROM mileageLog
> GROUP By riderId
> HAVING rideDistance >99
>
> It tells me that rideDistance is not part of an
aggregate function. I thought
> to get around this I just had to have each variable
called for in the SELECT
> line?
>
in the SELECT statement change rideDistance to
SUM(rideDistance) - i
think that is what you want to get anyway, isn't it? - and
you won't get
that error. it's not the SELECT statement you have to have
the vars
listed in; it's either in the GROUP BY or use an aggregate
function on it..
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com

Similar Messages

  • How to get this with Single query

    Friends
    I am sure using SQL analytical function, the following can be achieved using a single query:
    Date_value | Cust_id | Customer_tenue | avg_bal
    01-aug-09 | 111 | 0 | 1000
    01-aug-09 | 112 | 1 | 2000
    01-aug-09 | 113 | 2 | 900
    01-aug-09 | 114 | 3 | 1250
    01-sep-09 | 111 | 1 | 1200
    01-sep-09 | 112 | 2 | 2000
    01-sep-09 | 113 | 3 | 1900
    01-sep-09 | 114 | 4 | 1250
    01-oct-09 | 111 | 2 | 1100
    01-oct-09 | 112 | 3 | 2200
    01-oct-09 | 113 | 4 | 1900Expected result
    If customer’s tenure is 0 then mark as ‘New’,
    If customer’s balance is increased from last month then mark as ‘Augment’
    If customer’s balance is same as last month then mark as ‘Maintain’
    If customer’s balance is decreased from last month then mark as ‘Diminish’
    Else ‘Left’
    Help please....

    If customer’s tenure in last month is 0 then mark as ‘New’,There's not such case in test data... last month is October, isn't it?
    SQL> with t as (select DATE '2009-08-01' Date_value, 111 Cust_id, 0 Customer_tenue, 1000 avg_bal from dual union all
      2  select DATE '2009-08-01', 112 , 1 , 2000 from dual union all
      3  select DATE '2009-08-01', 113 , 2 , 900 from dual union all
      4  select DATE '2009-08-01', 114 , 3 , 1250 from dual union all
      5  select DATE '2009-09-01', 111 , 1 , 1200 from dual union all
      6  select DATE '2009-09-01', 112 , 2 , 2000 from dual union all
      7  select DATE '2009-09-01', 113 , 3 , 1900 from dual union all
      8  select DATE '2009-09-01', 114 , 4 , 1250 from dual union all
      9  select DATE '2009-10-01', 111 , 2 , 1100 from dual union all
    10  select DATE '2009-10-01', 112 , 3 , 2200 from dual union all
    11  select DATE '2009-10-01', 113 , 4 , 1900 from dual)
    12  select date_value, cust_id, avg_bal, oldbal, case when Customer_tenue=0 and nextbal is null then 'NEW'
    13                                                    when oldbal<avg_bal then 'Augment'
    14                                                    when oldbal=avg_bal then 'Maintain'
    15                                                    when oldbal>avg_bal then 'Diminish'
    16                                                    else 'Left' end status
    17    from (select date_value, cust_id, customer_tenue, avg_bal, LEAD(avg_bal) over (partition by cust_id order by date_value desc) oldbal,
    18                 LAG(avg_bal) over (partition by cust_id order by date_value desc) nextbal
    19            from t)
    20  order by cust_id, date_value;
    DATE_VALU    CUST_ID    AVG_BAL     OLDBAL STATUS
    01-AGO-09        111       1000            Left
    01-SET-09        111       1200       1000 Augment
    01-OTT-09        111       1100       1200 Diminish
    01-AGO-09        112       2000            Left
    01-SET-09        112       2000       2000 Maintain
    01-OTT-09        112       2200       2000 Augment
    01-AGO-09        113        900            Left
    01-SET-09        113       1900        900 Augment
    01-OTT-09        113       1900       1900 Maintain
    01-AGO-09        114       1250            Left
    01-SET-09        114       1250       1250 Maintain
    Selezionate 11 righe.Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com/2009/12/29/estrarre-i-dati-in-formato-xml-da-sql/]

  • I used to drag and drop newly loaded CD's from Recently Added to one of my iPod Classic playlists. I have no idea how to do this with the new version of iTunes. I thought perhaps checking Sync might give me a clue but it warned me Syncing would wipe conte

    I used to drag and drop music loaded from CD's from the Recently Added folder to a Playlist on my iPods Classic. Can't see how to do this with new iTunes version. Probably need to sync somehow but when I checked on Sync it warned me it would wipe out my iPod contents. Don 't know why Apple makes something that used to be simple so difficult. Can't even figure out how to display both my library and iPod contents on same screen.

    Hey joshuafromisr,
    If you resintall iTunes, it should fix the issue. The following document will go over how to remove iTunes fully and then reinstall. Depending on what version of Windows you're running you'll either follow the directions here:
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    http://support.apple.com/kb/HT1925
    or here:
    Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
    http://support.apple.com/kb/HT1923
    Best,
    David

  • Aggregating table - how to solve this with ADF Faces

    Hello.
    I am trying to solve something that would typically be really simple. However, now i' using ADF faces which is new to me and i'm stuck.
    I want to show a table of rows with aggregated numbers (department in example below) and then "open up" any row by clicking on it to display the numbers that make up the aggregate (the guys in the helpdesk department in the example below).
    Something like this:
    DEPARTMENT SALARIES
    +Sales                  1.234.567
    +Warehouse         3.425.553
    -Helpdesk 655.000
    Joe 155.000
    Jill 300.001
    Burt 199.999
    +Personnel           546.225
    +Management     9.646.383
    And to make things more complicated, some of the aggregate rows in my real life example don't have any underlying rows. They just have the total. Can anyone give me hint about how to do this with an ADF Faces-control? I need to show management this can be solved quick and simple with ADF Faces, so i can convince them that it is the way we should be working in the future.
    Edited by: GoodCoffee on Jun 2, 2009 4:15 AM. Trying to indent the three rows under "Helpdesk"

    Hi,
    if you use ADF BC as the business Service then you can create a transient attribute (one that does not ave a database column ) and compute the total. Using JDeveloper 11g, you can use a Groovy expression. The below example calculates the Overall Salary paid by an department. The transient attribute is defined on the Department Entity Object
    XML View
    <Attribute
        Name="SumSalary"
        ColumnName="SUMSALARY"
        SQLType="NUMERIC"
        Type="java.lang.Long"
        ColumnType="NUMBER"
        IsQueriable="false"
        IsPersistent="false">
        <TransientExpression><![CDATA[Employees1.sum("Salary")]]></TransientExpression>
      </Attribute>The Employees1.sum("Salary") string is the Groovy expression that you need to add for the attribute. You select the created transient attribute in the EO editor and press the pencil icon. Then you select "Expression" as the value type and add the string.
    See: http://www.oracle.com/technology/products/jdev/11/how-tos/groovy/introduction_to_groovy.pdf
    Frank

  • How to do this with message mapping in PI  ?

    Hi All,
    Field 1 = 100 characters having values in  first fifty characters and last 50 characters blank . I need to remove all the first 50 characters with blank and pass 100 blank characters .How to do this with message mapping
    Thanks

    Adding to that, since usually a tab = 8 spaces. What you can do is to open notepad, press tab 4 times. Copy it and paste 3 times, afterwards press space 4 more times and you get 100 spaces.
    Regards,
    Mark

  • HT201303 last time i bought apps by using visa gift card so iam trying to use the kind of visa gift card and the system is denying the method payment ....any idea how to solve this with my itune account ?

    last time i bought apps by using visa gift card so iam trying to use the kind of visa gift card and the system is denying the method payment ....any idea how to solve this with my itune account ?

    A few reasons I can think of, but instead of shooting in the dark, lets check with experts who can look at your account.
    iTunes Store Support
    http://www.apple.com/emea/support/itunes/contact.html

  • How do i chat with one of apples employees???

    how do i chat with one of apples employees???

    Chat support is available for MobileMe and selected iTunes Store topics only.
    MobileMe: Customer service and technical support
    iTunes Store: Customer Service
    Source: http://www.apple.com/support/contact/

  • I reset my phone and it now receives calls that were meant for my husband. I know how to fix this with messaging and facetime, but can't seem to find how to make it stop with the calls. Please help.

    I reset my phone and it now receives calls that were meant for my husband. I know how to fix this with messaging and facetime, but can't seem to find how to make it stop with the calls. Please help.

    It may be due to Continuity
    The following quote is from  Connect your iPhone, iPad, and iPod touch using Continuity
    Turn off iPhone cellular calls
    To turn off iPhone Cellular Calls on a device, go to Settings > FaceTime and turn off iPhone Cellular Calls.

  • Multiple charts with one Query - how to?

    Hi Experts,
    I  wanted to display mulitple charts from the one query in Bex analyzer or WAD. Each chart should be constructed from the data of each column returned from the query. So if the no. of columns in the query is 5  then there should be 5 charts generated. No of columns will be variable. How to achieve it ?? Any idea?
    All kinds of suggestions are welcome.
    Thanks
    Regards
    AB

    Hi Priya,
    Thanks for your response. Actually the infomation is of technical in nature. Its about processes and the parts. Rows represents  parts and columns represent processes. The processes are variable and can be added any time in query.Based on the Query there should be automation of charts. So there is an analysis per process/parts with a single chart. So if the processes are increasing , the automation should also add a chart....thats what the requirement says. So if I have 10 process that I shd get 10 charts and if 15 afterwards then 15....
    I hope now its clear to you.Do suggest if u have any idea.
    Regards
    Atul

  • 5 reports with one query ....?

    Hi Guys,
    We  are on BI 7 and ECc 6...In one of our MM Report requirements we have one report with 5 work books ...i.e,
    The report is a set of 5 reports with the same selection criteria with different Key figures.
    All these reports can be separate work sheets in a workbook or displayed in multiple table items in a Web report
    So , I have made one Query with all the Key Figures...and saved it...Now my question is Do I need to create 5 queries for this / 1 query is ok ?I didnt understand how to finish this...We have all the fields that we need for 5 reports in this query...
    Can  any one advice on this
    regards

    Hi,
    U can also create structures of 1query and save, then similarly create 4 remainign strucutres,,so totally u hv 5structures for 1query, (Instead of maintaining a workbuk)
    u can compare the data thru excel.
    Also check these links for checking data consistency,
    R/3 - BW reconcilation
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/968dab90-0201-0010-c093-9d2a326969f1
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/7a5ee147-0501-0010-0a9d-f7abcba36b14
    Reconsilation
    Please check this link for data reconcilation:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/7a5ee147-0501-0010-0a9d-f7abcba36b14
    Re: Reconcilation of data
    strategies and methods to reconcile sap bw data to source systems .
    http://bluestonestep.com/component/option,com_docman/task,doc_download/gid,7
    http://sap.ittoolbox.com/documents/popular-q-and-a/comparing-data-between-r3-and-bw-2741
    assign points if helped,.
    Thanks

  • How to Achieve this in SQL Query?

    How to Achieve this ?
    I have a table with numeric value populated like this
    create table random_numeral (numerals Number(10));
    insert into random_numeral values (1);
    insert into random_numeral values (2);
    insert into random_numeral values (3);
    insert into random_numeral values (4);
    insert into random_numeral values (5);
    insert into random_numeral values (6);
    insert into random_numeral values (56);
    insert into random_numeral values (85);
    insert into random_numeral values (24);
    insert into random_numeral values (11);
    insert into random_numeral values (120);
    insert into random_numeral values (114);
    Numerals
    1
    2
    3
    4
    5
    6
    56
    85
    24
    11
    120
    114
    I want to display the data as follows
    col1 / col2 / col3
    1 / 2 / 3
    4 / 5 / 6
    11 / 24 / 56
    85 / 114 / 120
    Can anyone Help me?

    I hope there might be some simple way to do this and waiting for experts to reply.
    Try the below query.
    SQL> select * from random_numeral;
      NUMERALS
             1
             2
             3
             4
             5
             6
            56
            85
            24
            11
           120
      NUMERALS
           114
           100
           140
    14 rows selected.
    SQL> select a.numerals ||' / '||b.numerals||' / '||c.numerals from
      2          (select numerals,rownum rn1 from
      3          (
      4              select numerals,mod(row_number() over(partition by 1 order by numerals),3)
      5              from random_numeral
      6          )
      7          where rn=1) a,
      8          (select numerals,rownum rn1 from
      9          (
    10              select numerals,mod(row_number() over(partition by 1 order by numerals),3)
    11              from random_numeral
    12          )
    13          where rn=2) b,
    14          (select numerals,rownum rn1 from
    15          (
    16              select numerals,mod(row_number() over(partition by 1 order by numerals),3)
    17              from random_numeral
    18          )
    19          where rn=0) c
    20  where   a.rn1=b.rn1(+)
    21  and b.rn1=c.rn1(+)
    22  /
    A.NUMERALS||'/'||B.NUMERALS||'/'||C.NUMERALS
    1 / 2 / 3
    4 / 5 / 6
    11 / 24 / 56
    85 / 100 / 114
    120 / 140 /
    SQL>Cheers,
    Mohana

  • How to Maintain Payment with one check for Multiple Vendors?

    Dear Gurus,
    i have a scenario for outgoing payment, here it is
    i have some open items for multiple vendors. say it for open item
    1. with amount 5000 USD for vendor A
    2. wiht amount 10000 USD for vendor B
    my company pay both open item 1 & 2 with one check, say the check no is 27382830 and the amount is 15000 USD. The check is given to the Bank as an order to Pay the vendor. so the check does not have receiver name. i attach a formal letter to the bank to ask them for making payment with that check. the letter contains a detail the amount, vendor bank account number, account holder, and the vendor name.
    so how i can threat this business scenario into SAP? i want to trace check number used to pay the vendors.
    hope you can give some clues. is it possible to maintain scenario above with automatic payment?
    best regards,
    land lord

    Hi,
    Yes you can map this scenario in SAP and use F110 for this. But you will also have to use some Z programs..
    1. For F110 FBZP configuration, maintain outgoing bank clearing Account (this will be a dummy account and not the actual Outgoing Bank Account) as the Bank Sub Account.
    By doing this when you run payment in F110, entry will be
    Vendor A A/c...Dr.
    outgoing bank clearing Account Cr.(1)
    Vendor B A/C... Dr.
    outgoing bank clearing Account Cr.(2)
    2.Then you will have to use Post with clearing transaction codes and make one entry
    outgoing bank clearing Account Cr.(1)..Dr.
    outgoing bank clearing Account Cr.(2)..Dr.
    To Bank Outgoing Account(Actual Bank outgoing Account) Cr.
    3. Now, when you get the single cheque no. from Bank against both the vendors, then thru FB02, change the assignment field/Reference field for Che No. updates.
    But do check BRS also for its reconciliation.. If you do it on a daily basis.. then it would not be difficult.
    Hope this helps you..
    Regards,
    SAPFICO

  • How to do this with Logic?

    Hy!
    Any ideas how i can realize this with Logic?:
    http://www.youtube.com/watch?v=tE7GHgbmlP0
    Are there any (freeware) loop plug ins or something else I could use?

    Yea, but what if we want to make our own loops, instead of using what apple is providing?
    If you're questioning whether you can make your own music loops in Logic as opposed to just using Apple Loops, then you're totally misunderstanding some of the most basic functioning of Logic. That's like asking whether you car will drive you around the block. Logic is a very complex multi track audio and midi sequencing program. Not only can you make any type of sound or audio or midi sequence and loop it to your heart's delight, you can make multi track sequences, songs, complex orchestral arrangements, movie scores, soundscapes .... shall I go on?
    I just got LP8, and I'm just learning it too. Are you really saying that you can't do anything similar to that video with Logic?
    Absolutely not!! In fact, SC's post 4th down tells you how to do something similar. Not EXACTY what's in the video, but SIMILAR.
    Here's the difference: You can't record a single measure drum beat and then have it automatically loop indefinitely *in real time* while you layer more drum beats onto it, each one being recorded after a single measure and played back without stopping. In Logic, you can record a measure, then tell Logic to loop it, and then create another, loop that one, etc etc. The only difference is you're not doing it in 'real time' without stopping, you're building a sequence of looped sounds manually in the arrange. The OP seems to want to do it live, without the beat stopping. For that you need Ableton or another program with 'real time looping' capabilities. The only reason you'd want to do this would be if you A) want to impress your friends, or B) are trying to create beats in a live situation, like a club or something. If that's what you're after, other programs like Ableton Live are better suited for that.

  • How to Perform this calculaction in Query

    Hi Experts
    How can i achieve this Calculaction at query Level.
    Data:
    Emp_ID--Wage_IDPayroll_Date--Amount
    1--03925.01.2008-5000
    1--03925.02.2008-5000
    1--03925.03.2008-5000
    1--03925.04.2008-6000
    1--03925.07.2008-6000
    The employee will have No of different Wage types in his pay run.
    But as per my requirment i want to calculacte Employee Salarly.
    Lets Consider Wage Type 039 which is Salarly
    The Cal i need to perform is
    Select the Wage Type 039 and then Select the Latest (25.07.2008) Payroll date and then select the amount assiociated with it for and the 12* amount give salarly
    In the above case aslarly should be 72,000

    Hi,
    Soluition can be the following:
    Put Pay_Roll_date also as a key-figure in your cube and add to columns.
    Add condition (top 1) on keyfigure,
    In Character Assignment tick ïndividual char. and Char combinations.
    Tick also Emp_id and Wage ID. do not tick Pay_Roll_date (the characteristics, not the keyfigure)
    Hide key-figure Pay_roll_date & Amount
    Make calculated keyfigure Salary = 12 * Amount.
    That should do it.
    Udo

  • How to put this condition in Query

    Dear experts,
    I have a scenario where in the calculation should be dynamic between key figures in query
    For example i have a
    Target Cost and Actualcost1, Actualcost2, Actualcost3
    i need to findout the variance between the Target and Actual
    but the catch is that i need to findout the variance with the latest actual cost
    1. )  Target cost = 100
    Actual cost1=10, Acutal cost2=0, actual cost3=0
    then the formula should be Actual cost1-target cost
    2. )But if
    Target cost  =100
    Actual cost1=10, Actual cost2=5, Actual cost3=0
    then the formula should be Actual cost2- Target cost
    3. Target cost =100
    Actual cost1=10, Actual cost2 = 5, Actual cost3= 15
    then the formula should be Actual Cost3-Target cost
    How to achieve this
    Thanks and regards
    Neel

    Hi Neel,
    Do you have indicator saying that a particular actual cost is the latest? If you have any indicator thsi would make the job easy. Else you need to create new formulas to derive the logic.
    Else you can proceed with the belwo logic.
    1.target cost
    2. Actual Costs 1 - Hide
    3. Actual Costs 2 - Hide
    4. Actual Costs 3 - Hide
    5. New formula whcih evaluates the latest.
    Write the condition
    If Actual costs3 = 0 and actual cost2 = 0 then actual cost1.
    else if actual cost2= 0 then actual cost1
    else if actual cost1 NE 0 and actual cost2 NE 0 then Actual cost3.
    Then hide the above new formula.
    And in a new formula you can find the diff between the Target cost and the latest cost derived in teh above new formula.
    If the conditions is too big in the above new formula, you can split across two three new formulas and derive the logic.
    Just make some changes to the above logic if it is not 100%.
    I believe this logic will work.

Maybe you are looking for