Azure SQL Server – large query to select a failed execution plan

Let's just throw this out: If a query is big and confusing, it's probably also big and confusing for the optimizer.

Should I specify the join type and index name for each join to keep the original execution plan? Is that the best way?

No, because these hints may not always be the right choice.

It would probably make more sense to inherit the part of the query for which you get a good plan and copy it to a dump #temp Table.

From there, add your other shortcuts to the temporary table. That way, the optimizer has less bad decisions to make. Sure, you may have to put an index on the temp table, but that's a lot less painful than putting together a bunch of brittle cues.

To select the correct subnet mask

I have the IP address and must have 2 subnets and 30 hosts each. How do I choose the right subnet mask?

I tried this and said that a / 27 would be fine since I would get 30 hosts. However, I can not figure out how many subnets I would get because it's a class A address with a / 27 mask.

16.04 – Select repository error

Ubuntu 16.04
When choosing a repository I have three options for this country and all have issued this error.

All repository indexes could not be downloaded

The repository may no longer be available or could not be contacted due to network issues. If available, an older version of the failed index will be used. Otherwise, the repository is ignored. Check your network connection and make sure the repository address is correct in the settings.

An error occurred during signature verification. The repository will not be updated and the previous index files will be used. GPG Error: stable Release: The following signatures were invalid: KEYEXPIRED 1555048520 KEYEXPIRED 1555048520 KEYEXPIRED 1555048520 KEYEXPIRED 1555048520Note: The following signatures were invalid: KEYEXPIRED 1555048520 KEYEXPIRED They were ignored or used instead.

Can someone help fix that?
Many Thanks

PostgreSQL Index Only Scan can NOT select ctid

I have a table A (id bigint, text text)and I have primary key btree on I would,

Now I want to pick up ctid Records meet some conditions like id = 823977776533426178,

But also with pg_hint_plan to instruct PostgreSQL Index Only ScanIt will always be mine Index scanlike the following:

/ * + IndexOnlyScan (a) * / explain select analysis ctid from a where id = 823977776533426178;
-------------------------------------------------- -------------------------------------------------- ------
Index scanning with a_pkey for a (cost = 0.14..8.16 lines = 1 width = 6) (actual time = 0.038..0.039 lines = 1 loops = 1)
Index Cond: (id = & # 39; 823977776533426178 & # 39; :: bigint)
Planning time: 0.122 ms
Execution time: 0.095 ms
(4 rows)

My understanding is ctid is the physical record ID (block_no: record_offset) of each record and must be included in each Btree index because each index needs this information to retrieve the record from the heap file.

Why can not an index just return the scan? ctid directly?
Is it just that PostgreSQL does not implement this?

By the way, my trial version is PostgreSQL-11.

Many Thanks!

Google Sheets – Select the line with the best price for articles with multiple versions / upgrades

I'm sure my problem is pretty easy to solve, but I've been around for a while and may need some help.

I have a huge table, but the problem boils down to it: some articles have two versions (one normal and one updated), and I just want to be able to see the best version of an item (if any, updated). the normal otherwise).

Example table:

Name | Value | kind
Tool A | 50 | Tool A
Tool A [U] | 75 | Tool A
Tool B | 100 | Tool B
Tool C | 200 | Tool C
Tool B [U] | 150 | Tool B

And I would like to get

Name | Value | kind
Tool A [U] | 75 | Tool A
Tool C | 200 | Tool C
Tool B [U] | 150 | Tool B

Note: It can only be upgraded, and the basic version of the "Tools" is always available if it helps.

I can easily pick the best value for tool A, B or C, but choosing the name (and other properties) is the problem.

I tried something like this CHOOSE A, MAX (B), C GROUP BY Cbut it throws errors back at me.

Attempt to select nth items from a list

I try to take over the nth element of each sublist. Below is an example list:

exlist = {{{1,2}, {2,6}, {4,1}}, {{2,3}, {3,1}, {2,4}}, {{5,6}, {7,5}, {6,7}}};

want: {{{1,2}, {2,3}, {5,6}}, {{2,6}, {3,1}, {7,5}, {{4,1}, { 2.4}, {6,7}}}

I tried to use [[All, 1]]but my actual code goes up to 20 and I want it to be automated so I do not have to type it [[All, 1]],[[All, 2]],[[All, 3]], This could be easier than I thought, but I could not find an alternative. Many Thanks!

sql – Select number from two different columns of the same table

Hello good day, the doubt is that I want to ask a question. a survey
I have

The 0 means that he said "no" and 1 "yes". My table is:

Question 1 Question 2 Question 3
1 0 1
0 1 1

What I want to do is to count the number 1 and the number 0.

But I do not know how to grab those from different columns and count, I did something like this:

Select COUNT as p1, + COUNT as p2, + COUNT as p3, + COUNT as p4
from rs_calificacion_ticket
Where question1 = 1 or question2 = 1 or question3 = 1 or question4 = 0
Group after Question1, Question2

But it did not work

Work on the engine sql managent studio v17.9

Any help or explanation about the experts that exist in this community.Enter the description of the picture here

SQL Server – Use a calculated column in a SQL Select statement

I'm trying to write a request. Column A is from the database, Column B is either 1 or -1 and is the result of a CASE statement looking at the same table. Now, my column C needs to point to column B as part of its calculation (say, it's Column_B * Column_X). How do I do this because I can not use Column_B in my SELECT statement?