Is there a way to add all the marks under total Column?
This is my school project work.
The Question is to create a query and show ROll Number and Name and total marks
obtained by each student using both the table while adding fields in query.
There is no intrinsic function to sum multiple fields. If your table structure were normalized could do a CROSSTAB query. Otherwise, build a simple SELECT query that constructs the Total field with an expression:
[Bengali]+[English]+[Maths]+[Physics]+[Chemistry].
Be aware that if any field is Null the expression will return Null. If needed, deal with possible Null in each field: Nz([Bengali],0) or some recommend Iif([Bengali] Is Null, 0, [Bengali]).
There is no need to have Total field in table. Calculate the value when needed. However, starting with Access2010 could use a Calculated type field in table. Some developers despise their use but they do work. They do have limitations, for instance the Nz() will not work nor will Is Null. IIf(IsNull([Bengali]),0,[Bengali]).
Related
Can someone explain the purpose of using bitwise operators(like BIT_OR) in MySQL queries. For example, if have a table such as following:
What is the purpose of aggregate operation like:
SELECT name FROM table GROUP BY name HAVING BIT_OR(value) = 0;
What exactly does the BIT_OR do? I understand the actual operation of converting two integers to binary and determining if each pair of corresponding digits are either 0 or 1(if at least one of them is a 1), but what happens with varchar or other non-number columns columns? I know for example, SUM aggregate function can give me the sum of a column of each group. Likewise, what does BIT_OR tell me for each group?
**NOTE:**I randomly created the above table and query - it doesn't illustrate any specific problem
This is my current table, let's call it "TABLE"
I want end result to be:
I tried this query:
SELECT * FROM TABLE GROUP BY(service)
but it doesn't work
i tried replacing NULL with 0 and then perform group by but "TBA" (text value) is creating problem, kindly help me out!
This looks like simple aggregation:
select service, max(for1) for1, max(for2) for2, max(for3) for3
from mytable
group by service
This takes advantage of the fact that aggregate functions such as max() ignore null values. However if a column has more than one non-null value for a given service, only the greatest will appear in the resultset.
It is unclear what the datatype of your columns is. Different datatypes have different rules for sorting.
Is there any function or node which will add the number of elements in a set chronologically?
I would like to create a simple line graph of "total number of users" over time, but what I have is "user_email" (unique) and "date_created" for the date the user joined.
What is the easiest way to sum the number of users at any given time from their creation date and plot it in a graph according to time?
I tried searching for this, but didn't find anything related. New to KNIME. Thanks.
If you are sure that user_email only contains unique values, you can sort the table by date_created (if it isn't already sorted) then use a Counter Generation node to add a column containing a counter value.
For a more general solution, if you want to count the cumulative total of unique values in a table column, you can use this sequence:
GroupBy configured to group by the column whose unique values you want to count and to aggregate on the column you want to plot this against - for example, your timestamp column, probably with either the First or Last aggregation method
Sorter to sort on the aggregation column from GroupBy
then Moving Aggregation with the Cumulative computation box checked, and configured to aggregate on Count of the grouped column from GroupBy.
If I have a table like so:
Name Type Val
Mike A 1
John A 4
Jerry 6
(Notice that Jerry has an empty string for Type)
And I do a query like
Select sum(Val), Type from table
How does MySQL choose which Type to put in the one row result? If I wanted to return the "non blanked"
To give some context, the Type for every row in this table should actually be the same, but there used to be a bug where there are now some values that are blank. (Note that the sum should still include the blanks)
I know I can do this in two queries, and just select Type from table where Type!="" but I was curious if there was a trick to do it in that single query.
This is valid SQL in MySQL. You are aggregating all rows to one row (by using the aggregate function SUM and having no GROUP BY clause).
Any value that is neither in a GROUP BY clause nor being aggregated is a random one. The type you get is just one of those types in the table; it could even be another one when you execute the same query again.
You can use max(type) or min(type) for instance to get the value you are after.
I have a fairly complex OLAP database, which basically amounts to a "header" record, and a huge number of "Members" which belong to that header.
My current MDX query gets the aggregated sum "Value" of members sliced by Age band and type of member. Here is the query:
SELECT
(
[Measures].[Member Value]
)
ON COLUMNS,
NON EMPTY
(
{
[Header].[Client Hierarchy].[Group Name].&[The Company]&[UK]&[ABC Group],
[Header].[Client Hierarchy].[Group Name].&[The Company]&[UK]&[DEF Group]
}
[Header].[Member Type].[Member Type],
[Member].[Age Band].[Age Band]
)
ON ROWS
FROM [Cube]
WHERE
(
[Header].[Another Attribute].&[Something],
[Header].[Created Date].&[2010-12-31T00:00:00],
[Member].[A Boolean Attribute].&[False]
)
I am trying to add another measure to this query to get the number of members aggregated in each row of the resultset. I achieved this using this calculated member:
WITH MEMBER [Measures].[Member Count] AS
COUNT(
EXISTING ([Member].[Id].[Id],[Measures].[Member Value])
,EXCLUDEEMPTY
)
And of course added it into the COLUMNS
SELECT
(
[Measures].[Member Value],
[Measures].[Member Count]
)
...
However this chnages the query from taking ~1second originally to ~1:14minutes
Im thinking this is more to do with my cube structure than the query itself, does anyone have any hints as to what I need to change in my cube structure, or possibly a more efficient way of querying the same thing? I have seen some examples online of using SUM rather than count but they were more to do with COUNT and FILTER together.
One possible solutions is adding a new measure in your cube that retrieves this information.
Change your fact table adding a new column with the [Member].[Id].[Id] if it's not already there. Create a 'distinct count' measure on this column -> [Member Count]. Now this measure is retrieving the information you're looking for, note that in your facts you can not have null values in the column pointing to [Measures].[Member Value].
Another version is using SCOPE functionality of ssas, not sure if this will improve performance but it's likely.
For the record I determined that I already had a Measure that would sum up my records.
The member table had a measure which represented "The number of members this record represents" This had a 1 in it for all the records I was looking at (single members). Simply adding this measure summed that value across my slice.