Search Results

Search found 9706 results on 389 pages for 'aggregate functions'.

Page 17/389 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • Calling DLL functions from VB6.

    - by Tim Ring
    I've got a Windows DLL that I wrote, written in C/C++ (all exported functions are 'C'). The DLL works fine for me in VC++. I've given the DLL to another company who do all their development in VB. They seem to be having a problem linking to the functions. I haven't used VB in ten years and I don't even have it installed. What could be the problem? I've declared all my public functions as follows: define MYDCC_API __declspec(dllexport) MYDCCL_API unsigned long MYDCC_GetVer( void); . . . Any ideas? Finally got back to this today and have it working. The answers put me on the right track but I found this most helpful: http://www.codeproject.com/KB/DLL/XDllPt2.aspx Also, I had a few problems passing strings to the DLL functions, I found this helpful: http://www.flipcode.com/archives/Interfacing_Visual_Basic_And_C.shtml

    Read the article

  • Core Data: Multiple conditions inside relational aggregate operations

    - by Uzaak
    I have an SQLite table used by Core Data with the following elements: Name: John LastName: Foobar Age: 23 Name: Bob LastName: Baz Age: 37 Name: Peter LastName: Fooqux Age: 32 Name: John LastName: Bar Age: 29 Those are all in a to-many relationship from another object "Company". I need to query the database and retrieve all Company objects with employees called "John" but whose last name does NOT contain "Foo". I did go as far as to make the following predicate: [NSPredicate predicateWithFormat:@"ANY employee.name = 'John'"]; How do I get to filter only by companies whose Johns don't have "Foo" in their last names?

    Read the article

  • how to aggregate this data in R

    - by stevejb
    Hello, I have a data frame in R with the following structure. > testData date exch.code comm.code oi 1 1997-12-30 CBT 1 468710 2 1997-12-23 CBT 1 457165 3 1997-12-19 CBT 1 461520 4 1997-12-16 CBT 1 444190 5 1997-12-09 CBT 1 446190 6 1997-12-02 CBT 1 443085 .... 77827 2004-10-26 NYME 967 10038 77828 2004-10-19 NYME 967 9910 77829 2004-10-12 NYME 967 10195 77830 2004-09-28 NYME 967 9970 77831 2004-08-31 NYME 967 9155 77832 2004-08-24 NYME 967 8655 What I want to do is produce a table the shows for a given date and commodity the total oi across every exchange code. So, the rows would be made up of unique(testData$date) and the columns would be unique(testData$comm.code) and each cell would be the total oi over all exch.codes on a given day. Thanks,

    Read the article

  • [macosx]does dlopen call open and read functions?

    - by zbencik
    Hello, I've intercepted(interposed) dlopen function under MacOS X and some other functions. I see how my applications calls dlopen in the log, but don't find anything related to open/read functions after dynamic library was dlopened. How does the system accesses and reads the dynamic library file? I've looked at the source code of dyld, and it does call open/read on dlopen. Can anybody let me know what I'm missing? intercepted functions: dlopen, open, read, write, access, all stat functions, close, etc. thanks, any help is highly appreciated.

    Read the article

  • How cast in XML for aggregate functions

    - by renegm
    In SQL Server 2008. I need execute a query like that: DECLARE @x AS xml SET @x=N'<r><c>First Text</c></r><r><c>Other Text</c></r>' SELECT @x.query('fn:max(r/c)') But return nothing (apparently because convert xdt:untypedAtomic to numeric) How to "cast" r/c to varchar? Something like SELECT @x.query('fn:max(«CAST(r/c «AS varchar(20))»)') Edit: Using Nodes the function MAX is from T-SQL no fn:max function In this code: DECLARE @x xml; SET @x = ''; SELECT @x.query('fn:max((1, 2))'); SELECT @x.query('fn:max(("First Text", "Other Text"))'); both query return expected: 2 and "Other Text" fn:max can evaluate string expression ad hoc. But the first query dont work. How to force string arguments to fn:max?

    Read the article

  • Linq Aggregate on object and List

    - by Kris-I
    I do this query with NHibernate: var test = _session.CreateCriteria(typeof(Estimation)) .SetFetchMode("EstimationItems", FetchMode.Eager) .List(); An "Estimation" can have several "EstimationItems" (Quantity, Price and ProductId) I'd like a list of "Estimation" with these constraints : One line by "Estimation" code on the picture (ex : 2011/0001 and 2011/0003) By estimation (means on each line) the number of "EstimationItems" By Estimation (means on each line) the total price (Quantity * Price) for each "EstimationItems" I hope the structure will be clearer with the picture below. Thanks,

    Read the article

  • Returning multiple aggregate functions as rows

    - by SDLFunTimes
    I need some help formulating a select statement. I need to select the total quantity shipped for each part with a distinct color. So the result should be a row with the color name and the total. Here's my schema: create table s ( sno char(5) not null, sname char(20) not null, status smallint, city char(15), primary key (sno) ); create table p ( pno char(6) not null, pname char(20) not null, color char(6), weight smallint, city char(15), primary key (pno) ); create table sp ( sno char(5) not null, pno char(6) not null, qty integer not null, primary key (sno, pno) );

    Read the article

  • Linq order by aggregate in the select { }

    - by Joe Pitz
    Here is one I am working on: var fStep = from insp in sq.Inspections where insp.TestTimeStamp > dStartTime && insp.TestTimeStamp < dEndTime && insp.Model == "EP" && insp.TestResults != "P" group insp by new { insp.TestResults, insp.FailStep } into grp select new { FailedCount = (grp.Key.TestResults == "F" ? grp.Count() : 0), CancelCount = (grp.Key.TestResults == "C" ? grp.Count() : 0), grp.Key.TestResults, grp.Key.FailStep, PercentFailed = Convert.ToDecimal(1.0 * grp.Count() /tcount*100) } ; I would like to orderby one or more of the fields in the select projection.

    Read the article

  • Using reshape + cast to aggregate over multiple columns

    - by DamonJW
    In R, I have a data frame with columns for Seat (factor), Party (factor) and Votes (numeric). I want to create a summary data frame with columns for Seat, Winning party, and Vote share. For example, from the data frame df <- data.frame(party=rep(c('Lab','C','LD'),times=4), votes=c(1,12,2,11,3,10,4,9,5,8,6,15), seat=rep(c('A','B','C','D'),each=3)) I want to get the output seat winner voteshare 1 A C 0.8000000 2 B Lab 0.4583333 3 C C 0.5000000 4 D LD 0.5172414 I can figure out how to achieve this. But I'm sure there must be a better way, probably a cunning one-liner using Hadley Wickham's reshape package. Any suggestions? For what it's worth, my solution uses a function from my package djwutils_2.10.zip and is invoked as follows. But there are all sorts of special cases it doesn't deal with, so I'd rather rely on someone else's code. aggregateList(df, by=list(seat=seat), FUN=list(winner=function(x) x$party[which.max(x$votes)], voteshare=function(x) max(x$votes)/sum(x$votes)))

    Read the article

  • Installing PHP DOM functions on Apache

    - by user352556
    I have just moved my code over to a new server (running on Apache 2.2.3), and PHP's DOM functions are now returning "Fatal error: Class 'DOMDocument' not found". I did some research and it appears that the installation I am now on does not have PHP's DOM functions enabled. I need to enable these functions, so what is the quickest way to go about this? Is it doable from a configuration file or will it require installation of extensions? Thanks!

    Read the article

  • DBD::CSV: Problem with userdefined functions

    - by sid_com
    From the SQL::Statement::Functions documentation: Creating User-Defined Functions ... More complex functions can make use of a number of arguments always passed to functions automatically. Functions always receive these values in @_: sub FOO { my( $self, $sth, $rowhash, @params ); } #!/usr/bin/env perl use 5.012; use warnings; use strict; use DBI; my $dbh = DBI->connect( "DBI:CSV:", undef, undef, { RaiseError => 1, } ); my $table = 'wages'; my $array_ref = [ [ 'id', 'number' ], [ 0, 6900 ], [ 1, 3200 ], [ 2, 1800 ], ]; $dbh->do( "CREATE TEMP TABLE $table AS import( ? )", {}, $array_ref ); sub routine { my $self = shift; my $sth = shift; my $rowhash = shift; # return $_[0] / 30; }; $dbh->do( "CREATE FUNCTION routine" ); my $sth = $dbh->prepare( "SELECT id, routine( number ) AS result FROM $table" ); $sth->execute(); $sth->dump_results(); When I try this I get an error-message: DBD::CSV::st execute failed: Use of uninitialized value $_[0] in division (/) at ./so.pl line 27. [for Statement "SELECT id, routine( number ) AS result FROM "wages""] at ./so.pl line 34. When I comment out the third argument I works as expected ( because it looks as if the third argument is missing ): #!/usr/bin/env perl ... sub routine { my $self = shift; my $sth = shift; #my $rowhash = shift; return $_[0] / 30; }; ... 0, 230 1, 106.667 2, 60 3 rows Is this a bug?

    Read the article

  • Where and how to store functions in asp.net.vb

    - by si
    Hi. I am using visual studio 2008, asp.net.vb I have various functions; 1 that calculates totals, 1 that calculates averages, 1 that calculates percentages etc. The data they act upon is different depending on the particular web page, but all my pages use these functions. So I want to know how I can store these functions in a single place so that all of my web pages can access the routines. At the moment all I know how to do is to write seperate functions in the code-behind for each individual web page. Obviously that is just so long winded and inefficient, but try as I might I can't figure out how to do it better. Please can anyone help. Many thanks.

    Read the article

  • Lua - How to use functions from another script

    - by Person
    I'm wondering how to use functions from another script in Lua. For example, say GameObjectUtilities holds functions that many GameObject scripts will use. The Slime (a GameObject) script wants to use a function in GameObjectUtilities. I'm having trouble getting this to work. I've looked here, but I still don't really fully understand. Do I need to create a module or a table to hold the functions in GameObjectUtilities for the functions in it to be used in other scripts? If so, what is the best way to go about this?

    Read the article

  • "reduce" or "apply" using logical functions in Clojure

    - by Alex B
    I cannot use logical functions on a range of booleans in Clojure (1.2). Neither of the following works due to logical functions being macros: (reduce and [... sequence of bools ...]) (apply or [... sequence of bools ...]) The error saying that I "can't take value of a macro: #'clojure.core/and". How to apply these logical functions (macros) without writing boilerplate code?

    Read the article

  • SQL aggregate query question

    - by Phil
    Hi, Can anyone help me with a SQL query in Apache Derby SQL to get a "simple" count. Given a table ABC that looks like this... id a b c 1 1 1 1 2 1 1 2 3 2 1 3 4 2 1 1 ** 5 2 1 2 ** ** 6 2 2 1 ** 7 3 1 2 8 3 1 3 9 3 1 1 How can I write a query to get a count of how may distinct values of 'a' have both (b=1 and c=2) AND (b=2 and c=1) to get the correct result of 1. (the two rows marked match the criteria and both have a value of a=2, there is only 1 distinct value of a in this table that match the criteria) The tricky bit is that (b=1 and c=2) AND (b=2 and c=1) are obviously mutually exclusive when applied to a single row. .. so how do I apply that expression across multiple rows of distinct values for a? These queries are wrong but to illustrate what I'm trying to do... "SELECT DISTINCT COUNT(a) WHERE b=1 AND c=2 AND b=2 AND c=1 ..." .. (0) no go as mutually exclusive "SELECT DISTINCT COUNT(a) WHERE b=1 AND c=2 OR b=2 AND c=1 ..." .. (3) gets me the wrong result. SELECT COUNT(a) (CASE WHEN b=1 AND c=10 THEN 1 END) FROM ABC WHERE b=2 AND c=1 .. (0) no go as mutually exclusive Cheers, Phil.

    Read the article

  • Need help optimizing this Django aggregate query

    - by Chris Lawlor
    I have the following model class Plugin(models.Model): name = models.CharField(max_length=50) # more fields which represents a plugin that can be downloaded from my site. To track downloads, I have class Download(models.Model): plugin = models.ForiegnKey(Plugin) timestamp = models.DateTimeField(auto_now=True) So to build a view showing plugins sorted by downloads, I have the following query: # pbd is plugins by download - commented here to prevent scrolling pbd = Plugin.objects.annotate(dl_total=Count('download')).order_by('-dl_total') Which works, but is very slow. With only 1,000 plugins, the avg. response is 3.6 - 3.9 seconds (devserver with local PostgreSQL db), where a similar view with a much simpler query (sorting by plugin release date) takes 160 ms or so. I'm looking for suggestions on how to optimize this query. I'd really prefer that the query return Plugin objects (as opposed to using values) since I'm sharing the same template for the other views (Plugins by rating, Plugins by release date, etc.), so the template is expecting Plugin objects - plus I'm not sure how I would get things like the absolute_url without a reference to the plugin object. Or, is my whole approach doomed to failure? Is there a better way to track downloads? I ultimately want to provide users some nice download statistics for the plugins they've uploaded - like downloads per day/week/month. Will I have to calculate and cache Downloads at some point? EDIT: In my test dataset, there are somewhere between 10-20 Download instances per Plugin - in production I expect this number would be much higher for many of the plugins.

    Read the article

  • Increasing understanding of validating a string with PHP string functions

    - by user1554264
    I've just started attempts to validate data in PHP and I'm trying to understand this concept better. I was expecting the string passed as an argument to the $data parameter for the test_input() function to be formatted by the following PHP functions. trim() to remove white space from the end of the string stripslashes() to return a string with backslashes stripped off htmlspecialchars() to convert special characters to HTML entities The issue is that the string that I am echoing at the end of the function is not being formatted in the way I desire at all. In fact it looks exactly the same when I run this code on my server - no white space removed, the backslash is not stripped and no special characters converted to HTML entities. My question is have I gone about this in the wrong approach? Should I be creating the variable called $santised_input on 3 separate lines with each of the functions trim(), stripslashes() and htmlspecialchars()? By my understanding surely I am overwriting the value of the $santised_input variable each time I recreate it on a new line of code. Therefore the trim() and stripslashes() string functions will never be executed. What I am trying to achieve is using the "$santised_input" variable to run all of these PHP string functions when the $data argument is passed to my test_input() function. In other words can these string functions be chained together so that I only need to create $santised_input once? <?php function test_input($data) { $santised_input = trim($data); $santised_input = stripslashes($data); $santised_input = htmlspecialchars($data); echo $santised_input; } test_input("%22%3E%3Cscript%3Ealert('hacked')%3C/script%3E\ "); //Does not output desired result "&quot;&gt;&lt;script&gt;alert('hacked')&lt;/script&gt;" ?>

    Read the article

  • need help in aggregate select

    - by eugeneK
    Hi, i have a problem with selecting some values from my DB. DB is in design stages so i can redesign it a bit of needed. You can see the Diagram on this image Basically what i want to select is select c.campaignID, ct.campaignTypeName, c.campaignName, c.campaignDailyBudget, c.campaignTotalBudget, c.campaignCPC, c.date, cs.campaignStatusName ***impressions, ***clicks, ***cast(campaignTotalBudget-(clicks*campaignCPC) as decimal(18,1)) as remainingFunds from Campaigns as c left join CampaignTypes as ct on c.campaignTypeID=ct.campaignTypeID left join CampaignStatuses as cs on c.campaignStatusID=cs.campaignStatusID left join CampaignVariants as cv on c.campaignID=cv.campaignID left join CampaignVariants2Visitors as c2v on cv.campaignVariantID=c2v.campaignVariantID left join Visitors as v on c2v.visitorID=v.visitorID ..... order by c.campaignID desc Problem is that Visitors table has column named isClick so i don't know the way to separate what is impression with isClick=false and what is click isClick=true so i can show nice form with all the stuff about campaign and visitors... I don't think to split Visitors to two tables like Impressions and Click is a good idea because again i would need to have Visitors with two more tables thanks

    Read the article

  • Problem about C++ class (inheritance, variables scope and functions)

    - by Luigi Giaccari
    I have a class that contains some data: class DATA Now I would to create some functions that uses those data. I can do it easily by writing member functions like DATA::usedata(); Since there are hundreds of functions, I would to keep an order in my code, so I would like to have some "categories" (not sure of the correct name) like: DATA data; data.memory.free(); data.memory.allocate(); data.file.import(); data.whatever.foo(); where memory, file and whatever are the "categories" and free, allocate and foo are the functions. I tried the inheritance way, but I got lost since I can not declare inside DATA a memory or file object, error C2079 occurs: http://msdn.microsoft.com/en-us/library/9ekhdcxs%28VS.80%29.aspx Since I am not a programmer please don't be too complicated and if you have an easier way I am all ears.

    Read the article

  • Get functions called with GDB

    - by Werner
    Hi, I am using GDB to understand a C++ program. I put a break in the middle of the running which turns to be something like: break main.cpp:500 and I would like to see which functions have been called before. I tried "backtrace" but it shows only info about main, as previous calls to previous functions have already finished. My question is how can I get (with GDB or another method) the info about which functions have been called before this point, even if the call has been returned. Thanks

    Read the article

  • T-SQL Self Join in combination with aggregate function

    - by Nick
    Hi, i have the following table. CREATE TABLE [dbo].[Tree]( [AutoID] [int] IDENTITY(1,1) NOT NULL, [Category] [varchar](10) NULL, [Condition] [varchar](10) NULL, [Description] [varchar](50) NULL, CONSTRAINT [PK_Tree] PRIMARY KEY CLUSTERED ( [AutoID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO the data looks like this: INSERT INTO [Test].[dbo].[Tree] ([Category] ,[Condition] ,[Description]) VALUES ('1','Alpha','Type 1') INSERT INTO [Test].[dbo].[Tree] ([Category] ,[Condition] ,[Description]) VALUES ('1','Alpha','Type 1') INSERT INTO [Test].[dbo].[Tree] ([Category] ,[Condition] ,[Description]) VALUES ('2','Alpha','Type 2') INSERT INTO [Test].[dbo].[Tree] ([Category] ,[Condition] ,[Description]) VALUES ('2','Alpha','Type 2') go I try now to do the following: SELECT Category,COUNT(*) as CategoryCount FROM Tree where Condition = 'Alpha' group by Category but i wish also to get the Description for each Element. I tried several subqueries, self joins etc. i always come to the problem that the subquery cannot return more than one record. The problem is caused by a poor database design which i cannot change and i run out of ideas to get this done in a single query ;-(

    Read the article

  • Elegant way to aggregate multi-dimensional array by index key

    - by Stephen J. Fuhry
    How can I recursively find the total value of all children of an array that looks something like this? [0] => Array ( [value] => ? // 8590.25 + 200.5 + 22.4 [children] => Array ( [0] => Array ( [value] => ? // 8590.25 + 200.5 [children] => Array ( [0] => Array ( [value] => 8590.25 // leaf node ) [1] => Array ( [value] => 200.05 // leaf node ) ) ) [1] => Array ( [value] => 22.4 // leaf node ) ) )

    Read the article

  • Elegant way to aggregate multi-demensional array by index key

    - by Stephen J. Fuhry
    How can I recursively find the total value of all children of an array that looks something like this? [0] => Array ( [value] => ? // 8590.25 + 200.5 + 22.4 [children] => Array ( [0] => Array ( [value] => ? // 8590.25 + 200.5 [children] => Array ( [0] => Array ( [value] => 8590.25 // leaf node ) [1] => Array ( [value] => 200.05 // leaf node ) ) ) [1] => Array ( [value] => 22.4 // leaf node ) ) )

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >