I can do this by looping the result of a simplified query:
var query = from myrecord in dt.AsEnumerable()
where myrecord.Field<string>("field1") == "value1" || myrecord.Field<string>("field1") == "value2"
select myrecord;
foreach(var myrecord in query)
{
//if value1, then "X"
//sum += field2
}
But, I want to know if i...
I'm looking for 'textbook' example of database to illustrate salient features of the aggregate functions (Max, Min, Sum, Avg and Count) when NULL values are involved.
I must be able to discuss and illustrate/present the usage of these aggregates function in the presence of NULLs with example queries and their answers, using mentioned da...
Alright, this problem is a little complicated, so bear with me.
I have a table full of data. One of the table columns is an EntryDate. There can be multiple entries per day. However, I want to select all rows that are the latest entry on their respective days, and I want to select all the columns of said table.
One of the columns is a...
I've been using GROUP BY for all types of aggregate queries over the years. Recently, I've been reverse-engineering some code that uses PARTITION BY to perform aggregations. In reading through all the documentation I can find about PARTITION BY, it sounds a lot like GROUP BY, maybe with a little extra functionality added in? Are they ...
Hi,
I'm creating an SSRS report which contains a table of orders, grouped by day.
Now I can easily get the max order value for the day and put it in the group header by using the SSRS MAX() function.
However, I also want to get the corresponding customer name who placed this order, and place this in the group header too.
We can assume...
Is it possible to use a subform's 'current' record set as the domain argument to DAvg() (etc.)?
Basically, I have a subform that displays a subset of records from a query. I would like to run DAvg() over this subset. This is how I've gotten around it:
=DAvg([FieldToAvg], [SubformQuery], "ChildField=Forms.MasterForm.MasterField And Fiel...
I'm working on creating a SQL query that will pull records from a table based on the value of two aggregate functions. These aggregate functions are pulling data from the same table, but with different filter conditions. The problem that I run into is that the results of the SUMs are much larger than if I only include one SUM function....
I have a schedule (Voyages) table like this:
ID Arrival Departure OrderIndex
1 01/01/1753 02/10/2009 0
1 02/11/2009 02/15/2009 1
1 02/16/2009 02/19/2009 2
1 02/21/2009 01/01/1753 3
2 01/01/1753 03/01/2009 0
2 03/04/2009 03/07/2009 ...
Hi,
I have the following 2 tables:
items:
id int primary key
bla text
events:
id_items int
num int
when timestamp without time zone
ble text
composite primary key: id_items, num
and want to select to each item the most recent event (the newest 'when').
I wrote an request, but I don't know if it could be written more efficient...
SELECT
count(distinct req.requirementid),
req.requirementid,
org.organizationid,
req.locationofposting,
org.registereddate
FROM OrganizationRegisteredDetails AS org,
RequirementsDetailsforOrganization AS req
WHERE org.organizationid = req.requirementid
ORDER BY
org.RegisteredDate desc
this shows me the error...
hi,
i have a DataTable that has a column ("Profit"). What i want is to get the Sum of all the values in this table. I tried to do this in the following manner...
DataTable dsTemp = new DataTable();
dsTemp.Columns.Add("Profit");
DataRow dr = null;
dr = dsTemp.NewRow();
dr["Profit"] = 100;
dsTemp.Rows.Add(dr);
dr = dsTemp.NewRow();
d...
I have a grouped query, and would like to filter it based on count(*)
Can I do this without a subquery?
This is what I have currently:
select *
from (select ID,
count(*) cnt
from name
group by ID)
where cnt > 1;
...
$query1 = "select *
from linkat_link
where emailuser = '$email2'
or linkname ='$domain_name2'
ORDER BY date desc
LIMIT $From,$PageNO";
id catid discription price
------------------------------------
1 1 domain name 100
2 ...
I'm trying to do a lookup on our demographioc table to display some stats. However, since out demographic table is quit big I want to do it in one query.
There are 2 fields that are important: sex, last_login
I want to be able to get the total number of logins for various date ranges (<1day ago, 1-7 days ago, 7-30 days ago, etc) GROUPE...
I am having some problems creating a query that gives me the average of a sum. I read a few examples here in stackoverflow and couldn't do it. Can anyone help me to understand how to do this please? This is the data I have:
Transaction_x0020_Number Product_x0020_Code Sales_x0020_Value Date Cashier
000356 350...
Good day gurus,
I have a script that populates tables on a regular basis that crashed and gave the above error. The strange thing is that it has been running for close to 3 months on the production system with no problems and suddenly crashed last week. There has not been any changes on the tables as far as I know.
Has anyone encounter...
Simplified table structure (the tables can't be merged at this time):
TableA:
dts_received (datetime)
dts_completed (datetime)
task_a (varchar)
TableB:
dts_started (datetime)
task_b (varchar)
What I would like to do is determine how long a task took to complete.
The join parameter would be something like
ON task_a = task_b AN...
self join- how to use the aggregate functions
select a.tablename,
b.TableName,b.UserName from Employee a inner join
Employee b on a.ColumnValue=b.ColumnValue
and and a.TableName <> b.TableName and
a.UserName=b.UserName
and also to check whether the same user has count of records i.e Employee a = count of records of Employee b...
Hi,
Suppose I have data in table X:
id assign team
----------------------
1 hunkim A
1 ygg A
2 hun B
2 gw B
2 david B
3 haha A
I want to know how many assigns for each id. I can get using:
select id, count(distinct assign) from
X group by id
orde...
Hi,
I have an app in app engine which has a lot (expected to be in the range of 10 million + ) of tuples in database. For creating reports based on that app, I need to do a lot of aggregate functions, especially COUNT().
Since GQL does not support COUNT(), the only option seems to be sharding - http://code.google.com/appengine/article...