I've a working custom formula put in the data validation box in column A in a Google spreadsheet to disallow entering duplicates in the same column A.
=countif($A$3:$A$1677,A3)<=1
Now i have another column, column B, and i want the above formula to be moved in column B from column A editing it in such a way that it offers the following :
+---+------------+-------------+
| | A | B | <-- the custom formula to be kept in column B only (in the data validation box).
+---+------------+-------------+
| 1 | John | MySQL | <-- if this row/data is already existing, then
| 2 | John | Oracle | <-- this entry is allowed (bcoz the data in this row do not match with data in the above row (considering both columns), and
| 3 | Viv | MySQL | <-- this entry is also allowed (bcoz the data in this row also do not match with data in the above two rows (considering both columns), and
| 4 | Al | SQL | <-- this entry is also allowed (bcoz the data in this row also do not match with data in the above three rows (considering both columns), but,
| 5 | Viv | MySQL | <-- this entry is NOT allowed (bcoz the data in this row entirely match with data in one of the above rows - row no. 3 (considering both columns).
+---+------------+-------------+
I have modified the aforementioned formula a little as below :
=countif($A$3:$B$1677,B3)<=1
But it does not fulfill the 2nd condition (Viv, MySQL) stated above.
Try this:
=COUNTIF(ARRAYFORMULA($A$3:$A$1677&$B$3:$B$1677),A3&B3)<=1
Instead of checking each column separately, you just join the values together and check to see if more that one of joined string exists!
Hope that helps!
Related
I have a section table and class Table
class table is designed in this way
(id,class_name,section_id)
one class has many sections like
--------------------------------------------
| SN | ClassName | Section_id |
--------------------------------------------
| 1 | ClassOne | 1 |
| 2 | ClassOne | 2 |
| 3 | ClassOne | 3 |
| 4 | ClassOne | 4 |
--------------------------------------------
Now i want to groupBy Only ClassName and display all the sections of that class
$data['classes'] = SectionClass::groupBy('class_name')->paginate(10);
i have groupby like this but it only gives me one section id
Try this way...
$things = SectionClass::paginate(10);
$data['classes']= $things->groupBy('class_name');
You are getting just one row because that is what GROUP BY does, groups a set of rows into a set of summary rows and returns one row for each group. In standard SQL, a query that includes a GROUP BY clause cannot refer to nonaggregated columns in the select list that are not named in the GROUP BY clause. For example, in SQL Server if you try the next clause
SELECT * FROM [Class] GROUP BY [ClassName]
You'll get the next error
"Column 'SN' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause"
Think about it, you are grouping by ClassName, and following your sample data, this will return just one row. Your SELECT clause includes column ClassName, which is easy to get because is the same in every single row, but when you are selecting another, which one should be return if only one has to be selected?
Now, things change a little bit in MySQL. MySQL extends the standard SQL use of GROUP BY so that the select list can refer to nonaggregated columns not named in the GROUP BY clause. This means that the preceding query is legal in MySQL. However, this is useful primarily when all values in each nonaggregated column not named in the GROUP BY are the same for each group. The server is free to choose any value from each group, so unless they are the same, the values chosen are nondeterministic. You can find a complete explanation about this topic here https://dev.mysql.com/doc/refman/5.6/en/group-by-handling.html
If you are expecting a result in one row, you can use GROUP_CONCAT() function to get something like
--------------------------------
| ClassName | Sections |
--------------------------------
| ClassOne | 1,2,3,4 |
--------------------------------
Your query must be something like:
select `ClassName`, group_concat(Section_id) from `class` group by `ClassName`
You can get this with a raw query in laravel or its up to you to find a way to get the same result using query builder ;)
If I use something like a SERIAL (which is a random number) for my table's primary key, how can I select a numbered row from my table? In MySQL, I just use the auto incremented ID to select a specific row, but not sure how to approach the problem with an arbitrary numbering sequence.
For reference, here is the table I'm working with:
+--------------------+------+-------+
| id | name | score |
+--------------------+------+-------+
| 235451721728983041 | ABC | 1000 |
| 235451721729015809 | EDF | 1100 |
| 235451721729048577 | GHI | 1200 |
| 235451721729081345 | JKL | 900 |
+--------------------+------+-------+
Using the LIMIT and OFFSET clauses will return the nth row. For example SELECT * FROM tbl ORDER BY col1 LIMIT 1 OFFSET 9 returns the 10th row.
Note that it’s important to include the ORDER BY clause here because you care about the order of the results (if you don’t include ORDER BY, it’s possible that the results are arbitrarily ordered).
If you care about the order in which things were inserted, you could ORDER BY the SERIAL column (id in your case), though it’s not always the case because transaction contention and other things could cause the generated SERIAL values to not be strictly ordered.
I have a problem to produce a SSRS report that is like this:
This is how my output from stored procedure looks like:
Company Code | Company Name | Product Code | Product Name
ICE001 | Nestle | ICE001a | Drumstick Chocolate
ICE001 | Nestle | ICE001b | Drumstick KitKat
ICE001 | Nestle | ICE001c | Drumstick Chocolate
ICE002 | Walls | ICE002a | Cornetto Chocolate
ICE002 | Walls | ICE002b | Cornetto Latte
ICE002 | Walls | ICE002c | Cornetto La Liga
So how can I achieve this report structure in SSRS with the current stored procedure? Is it achievable?
Actually, yes you can. These are the steps:
Drag a table into the SSRS.
Make it 2 columns and 1 row.
On the first column, select the field you want as the sub data which in this case, Product Code.
In 2nd column, put in Product Name.
Now for the main data. Right click on the first column, select:
Insert Row > Outside Group - Above
Put the main data field which is Company Code at the first row, first column.
Put the Company Name expression at the second column, first row of the table.
Design as your preferred and generate your report :)
Doubt it. But if you adjust your dataset as below and use a table report it is.
select distinct code,company from icecream
union
select productcode,productname from icecream
How to find the average of two columns and having the average(output) in the third column
Column A | Column B | Column C
-------------------------------
1 | 100 | 50.5
1 | 15 | 8
You need to add a new Data-Cell and write the average function by yourself, because Birt supports the average only within one column and not across two columns.
Add a data cell, set the type to decimal and write the average function. You can use the availible column bindings and add them with a double click to your function.
i am new to cassandra and i am trying to read a row from database which contains values
siteId | country | someMap
1 | US | {a:b, x:z}
2 | PR | {a:b, x:z}
I have also created an index on table using create index on columnfamily(keys(someMap));
but still when i query as select * from table where siteId=1 and someMap contains key 'a'
it returns an entiremap as
1 | US | {a:b, x:z}
Can somebody help me on what should i do to get the value as
1 | US | {a:b}
You can not: even if internally each entry of a Map|List|Set is stored as a column you can only retrieve the whole collection but not part of it. You are not asking cassandra give me the entry of the map containing X, but the row whom map contains X.
HTH,
Carlo