Group by Multiple columns and then count different value of same column

I want to achieve the result which tells me the number of males and females of each disability types in each district. each district can have multiple disabilities.

So far i have reached the following query :

  SELECT    DistrictId,    fb.DisabilityTypeId,    SUM(     CASE WHEN GenderId = 1 THEN 1 ELSE 0 END   ) AS Male,    SUM(     CASE WHEN GenderId = 2 THEN 1 ELSE 0 END   ) AS Female  FROM    Districts d    LEFT OUTER JOIN FormAddresses a ON d.Id = a.DistrictId    INNER JOIN PeopleForms pf ON a.PeopleFormId = pf.Id    INNER JOIN FormBeneficiaries fb ON pf.Id = fb.PeopleFormId    INNER JOIN FormPersonalInfos fp ON pf.Id = fp.PeopleFormId  where    a.IsDeleted = 0    AND pf.FormTypeId = 2    AND d.CityId = 3  GROUP BY    DistrictId,    fp.GenderId,   fb.DisabilityTypeId 

which gives the following result :

DistrictId  |   DisabilityTypeId    |   Male  | Female     1       |       2               |   1     |     0     3       |       2               |   0     |     3     5       |       16              |   1     |     0     5       |       20              |   2     |     0     5       |       20              |   0     |     1     

But i want to achieve the following result :

DistrictId  |   DisabilityTypeId    |   Male  | Female     1       |       2               |   1     |     3     5       |       16              |   1     |     0     5       |       20              |   2     |     1 

i somehow managed to get the expected result, but that with some complex sub-queries in the select clause of each gender which i didnt like and was not sure about the performance.

how can i write an efficient query for the desired result that i want?

Thanks.

Random Hyperlinks Not Working in Nested Columns with Lists

I am new here and have beginner level experience with WordPress so please bear with me if I am leaving out any pertinent information.

Towards the lower portion of this https://www.logicmanager.com/ca-solutions-menu/ landing page, I have a series of containers with columns and nested columns. Within these nested columns I have included hyperlinked text to list items. Ideally, all of the hyperlinked list items would click out to their respective landing pages.

However, for some reason unbeknownst to me, most of the hyperlinks are not working properly and the text items are un-clickable.

Does anyone know why this might be and how I can fix it? Are there any additional details I can provide to help resolve this issue? Is this forum even meant for questions like this?? Many thanks in advance!

Mysql: Any way to properly index 3 ENUM columns with the same options ? (A OR B OR C)

I have 3 enum() columns with the same option values inside.
I first tried to use the "set" datatype which originally was meant to do that (hold multiple values from a set) but it seems that datatype isn’t managed for 15+ years and isn’t even supporting an index.
Is there a nice way to index those 3 columns so I can use them in searched without destroying query performance ?

SELECT * FROM TABLE WHERE a=’x’ OR b=’x’ OR c=’x’

I thought about creating a virtual field which uses a boolean logic (&) on the 3 enum field-numbers and combines them into a large number but that’s quite a hack and not nice to maintain.

Has someone solved this sort of task elegantly ? (I do not want to use a support table and JOIN it, I want to stay with a single table)

Storing timeseries data with dynamic number of columns and rows to a suitable database

I have a timeseries pandas dataframe which dynamically increases the columns every minute as well as adds a new row:

Initial:

timestamp                100     200     300 2020-11-01 12:00:00       4       3       5 

Next minute:

timestamp                100     200     300   500 2020-11-01 12:00:00       4       3       5     0 2020-11-01 12:01:00      14       3       5     4 

The dataframe has these updated values and so on every minute.

so ideally, I want to design a database solution that supports such a dynamic column structure. The number of columns could grow to over 20-30k+ and since it’s one minute timeseries, it will have 500k+ rows per year.

I’ve read that relational db’s have a limit on the number of columns so that might not work here, but also, since I am setting the data for new columns and assigning a default value(0) to previous timestamps, I lose out on the DEFAULT param that’s there on MySQL.

Eventually, I will be querying data for 1 day, 1 month to get the data for the columns and their values.

Please suggest a suitable database solution for this type of dynamic row and column data.

Flexible table columns width, rows independent?

Hello,

i have HTML table with 3 rows.
the third row contains in the middle three columns that contains extraordinary long phrasesphrases which cause columns above these long columns to be long too and that looks bad, because above rows contains images so spacing is different.

How can i set the HTML table columns width to be flexible, i mean so the wide third row columns does not influence width of the columns in other rows of the same table?

Flexible table columns width, rows independent?

How can I make a best fit curve from a dataset from specific data columns in order to display it with their respective points?

I’ve got the next dataset:

 ArstreYSust = Dataset[{ <|"Velocidad [m/s]" -> 8,   "Fuerza de arrastre \[Theta]=2\[Degree] SIN FLAP [N]" -> 0.06,   "Fuerza de sustentación \[Theta]=2\[Degree] SIN FLAP [N]" ->    0.19, "Fuerza de arrastre \[Theta]=14\[Degree] SIN FLAP [N]" ->    0.14, "Fuerza de sustentación \[Theta]=14\[Degree] SIN FLAP \   [N]" -> 0.38,   "Fuerza de arrastre \[Theta]=20\[Degree] SIN FLAP [N]" -> 0.21,   "Fuerza de sustentación \[Theta]=20\[Degree] SIN FLAP [N]" ->    0.4, "Fuerza de arrastre \[Theta]=8\[Degree] CON FLAP [N]" ->    0.24, "Fuerza de sustentación \[Theta]=8\[Degree] CON FLAP [N]" \   -> 0.75|>,   <|"Velocidad [m/s]" -> 10,    "Fuerza de arrastre \[Theta]=2\[Degree] SIN FLAP [N]" -> 0.08,    "Fuerza de sustentación \[Theta]=2\[Degree] SIN FLAP [N]" ->    0.31, "Fuerza de arrastre \[Theta]=14\[Degree] SIN FLAP [N]" ->    0.2, "Fuerza de sustentación \[Theta]=14\[Degree] SIN FLAP [N]" \   -> 0.5, "Fuerza de arrastre \[Theta]=20\[Degree] SIN FLAP [N]" -> 0.3,   "Fuerza de sustentación \[Theta]=20\[Degree] SIN FLAP [N]" ->    0.68, "Fuerza de arrastre \[Theta]=8\[Degree] CON FLAP [N]" ->    0.35, "Fuerza de sustentación \[Theta]=8\[Degree] CON FLAP [N]" \   -> 1.36|>, <|"Velocidad [m/s]" -> 12,   "Fuerza de arrastre \[Theta]=2\[Degree] SIN FLAP [N]" -> 0.11,   "Fuerza de sustentación \[Theta]=2\[Degree] SIN FLAP [N]" ->    0.49, "Fuerza de arrastre \[Theta]=14\[Degree] SIN FLAP [N]" ->    0.28, "Fuerza de sustentación \[Theta]=14\[Degree] SIN FLAP \  [N]" -> 0.79,   "Fuerza de arrastre \[Theta]=20\[Degree] SIN FLAP [N]" -> 0.46,   "Fuerza de sustentación \[Theta]=20\[Degree] SIN FLAP [N]" ->    0.86, "Fuerza de arrastre \[Theta]=8\[Degree] CON FLAP [N]" ->    0.44, "Fuerza de sustentación \[Theta]=8\[Degree] CON FLAP [N]" \  -> 1.96|>, <|"Velocidad [m/s]" -> 14,   "Fuerza de arrastre \[Theta]=2\[Degree] SIN FLAP [N]" -> 0.15,   "Fuerza de sustentación \[Theta]=2\[Degree] SIN FLAP [N]" ->    0.72,   "Fuerza de arrastre \[Theta]=14\[Degree] SIN FLAP [N]" -> 0.4,   "Fuerza de sustentación \[Theta]=14\[Degree] SIN FLAP [N]" ->    1.12, "Fuerza de arrastre \[Theta]=20\[Degree] SIN FLAP [N]" ->    0.69, "Fuerza de sustentación \[Theta]=20\[Degree] SIN FLAP \  [N]" -> 1.32,   "Fuerza de arrastre \[Theta]=8\[Degree] CON FLAP [N]" -> 0.6,   "Fuerza de sustentación \[Theta]=8\[Degree] CON FLAP [N]" ->    3.17|>, <|"Velocidad [m/s]" -> 16,   "Fuerza de arrastre \[Theta]=2\[Degree] SIN FLAP [N]" -> 0.18,   "Fuerza de sustentación \[Theta]=2\[Degree] SIN FLAP [N]" -> 0.8,   "Fuerza de arrastre \[Theta]=14\[Degree] SIN FLAP [N]" -> 0.45,   "Fuerza de sustentación \[Theta]=14\[Degree] SIN FLAP [N]" ->    1.29, "Fuerza de arrastre \[Theta]=20\[Degree] SIN FLAP [N]" ->    0.78, "Fuerza de sustentación \[Theta]=20\[Degree] SIN FLAP \  [N]" -> 1.53,   "Fuerza de arrastre \[Theta]=8\[Degree] CON FLAP [N]" -> 0.71,   "Fuerza de sustentación \[Theta]=8\[Degree] CON FLAP [N]" ->    3.48|>}]; 

I’ve had already build my list plot.

BUt I don’t know how to build a fit curve directly from my dataset in order to include it in the show command. I need to do it this way for different columns.

Thanks for reading and for your help.

Turning columns result set into independant rows in MySQL

I am pretty new to this and have been struggling over one issue.

I have a result set which for each Opportunity in a table (id as primary key), provides a date for a first cashflow (DFCFW) as a column and the 10 following columns (CFW1, CFW2, …., CFW10) being the 10 possible cashflows for each of the 10 following years, expected as anniversary dates of the first cashflow.

I would like to create a view which displays, for all the opportunities, three columns: opportunity.id, date of the cashflow, cashflow; there should be 10 records for each opportunity.

Any suggestion how to achieve this ?

Thank you so much

Fred

MariaDB subqueries to same table and column resulting in several columns

I have a table and want to pick monthly minute data to compare column wize in 10.3.13-MariaDB

Tested and tested for hours and hours different approaches without success, one example is below. Some tests does not complain syntactically but takes forever, and some tests complains about column names not recognized. All subqueries if tested separately return the same number of records, each in one column.

`SELECT RD, OT1, OT2, OT3 FROM

(SELECT rdate from OO where month(rdate) = 7 and year(rdate) = 2006) AS RD,

(SELECT ot from OO where month(rdate)=7 and year(rdate) =2006) AS OT1,

(SELECT ot from OO where month(rdate)=7 and year(rdate) =2007) AS OT2,

(SELECT ot from OO where month(rdate)=7 and year(rdate) =2008) AS OT3;`

The result should be something like:

`RD OT1 OT2 OT3

2006-07-01 00:00:00 1.2345 2.1234 1.543

… … … …

2006-07-31 23:59:00 3.456 3.234 2.234`

And, no I dont want to use UNION because then they will still follow one after the other…

Any thoughts?!

Is there a better way of displaying ‘Count’ of records beside other columns in a select query?

I have a table with below structure :

Test1(c_num  number ,c_first_name varchar2(50), c_last_name varchar2(50)) 

1)There is a normal index on c_num column.

2)The table has nearly 5 million records.

I have a procedure as you can see below. I want to display the Count(*) along with other columns.I want to know if there are better ways of doing this so that we can have better performance.

create or replace procedure get_members(o_result out sys_refcursor)    is begin  open o_result for   select c_num,          c_first_name,          c_last_name,          (select count(*) from test1) members_cnt -->Is there a better way instead of doing this?   from test1;  end; 

Thanks in advance