how to write hive queries for following problems

i have a table with 10 columns ColumnNo Name Example DataType

Column1 athlete_name Michael Phelps STRING

Column2 age 23 INT Column3 country United States STRING

Column4 year 2008 INT

Column5 closing_date 8/24/2008 STRING

Column6 sport Swimming STRING

Column7 gold_medals 8 INT

Column8 silver_medals 0 INT

Column9 bronze_medals 0 INT

Column10 total_medals 8 INT

i have few queries to write

Find out the total number of medals won by each country in swimming  Find out the total number of medals won by India in each year  Find out the total number of medals won by each country and also display the name of the country  Find out the total number of gold medals won by each country  Find out the country got medals for Shooting for each year

How can I ensure only one instance of a micro-service queries a database and downloads files to shared storage at a time?

I have a micro-service that sends files to clients on request.
It acquires these files by querying a database where other users have saved details of the file.
The micro-service queries the database periodically, if there is a new file(s) it contacts artifactory and downloads the file to a shared storage that all instances of the micro-service use.
How can I ensure that only one instance queries and downloads files at a time?

Combining two queries in one

What I want is getting all names (first, middle, last) of the users along with each of their total hours of work which will be calculated by the SQL statement: CAST(SUM(timediff(dateTimeOut,dateTimeIn) as time).

I was able to achieve this with two queries, but somehow, I feel that this is inefficient (?):

$  sql = "SELECT id, firstName, middleName, lastName FROM users_info"; $  result = $  pdo->query($  sql);  $  rows = array();  while($  row = $  result->fetch()){      $  time = $  pdo->query(                 "SELECT CAST(SUM(timediff(dateTimeOut, dateTimeIn))                   as time) as totalHoursWorked                  FROM users_time WHERE user_id = {$  row['id']}"             )->fetch();       $  row['totalHoursWorked'] = $  time['totalHoursWorked'];      $  rows[] = $  row;  }  echo json_encode($  rows); 

I’ll use the json data for a DataTable.

users_info table +----+-----------+------------+----------+ | id | firstName | middleName | lastName | +----+-----------+------------+----------+ |  1 | Isabelle  | Luna       | Ibarra   | |  2 | George    | Boston     | Everett  | |  3 | Skyler    | Land       | Cohen    | +----+-----------+------------+----------+   users_time table: +---------+---------+---------------------+--------------------+ | time_id | user_id |     dateTimeIn      |    dateTimeOut     | +---------+---------+---------------------+--------------------+ |       1 |       1 | 2019-06-14 00:00:00 | 2019-06-16 09:00:0 | |       2 |       1 | 2019-06-15 00:00:00 | 2019-06-16 08:00:0 | |       3 |       2 | 2019-06-14 00:00:00 | 2019-06-16 09:30:0 | |       4 |       2 | 2019-06-15 00:00:00 | 2019-06-16 08:30:0 | |       5 |       3 | 2019-06-16 00:00:00 | 2019-06-16 09:00:0 | +---------+---------+---------------------+--------------------+ 

db-fiddle link : https://www.db-fiddle.com/f/vpozKbVoXxPoGzcsBkLL36/0

Queries on distribution of prime divisors by magnitude?

Erdos-Kac law state a typical number of magnitude $ n$ has $ \log\log n$ prime factors and we know probability of square free integers is $ \frac{6}{\pi^2}$ .

  1. What is the probability distribution of square free $ (a,b)$ balanced integers $ n$ where if $ p|n$ and $ q|n$ we have $ ap<q<bp$ ? What balancing parameters gets to $ \frac1{O(\log n)}$ probability?

I would think a typical square free number is $ (1-\epsilon,1+\epsilon)$ balanced for a constant $ \epsilon\in(0,1)$ with similar probability of $ \frac{6}{\pi^2}$ .

  1. What is the probability distribution of square free $ (a,b)$ balanced integers $ n$ where we know there is an integer $ r|n$ with magnitude $ n^{0.25\pm\epsilon’}$ where $ \epsilon’\in(0,0.25)$ ?

View GraphQL queries in browser network developer tools [on hold]

We recently migrated our API to graphql, and it’s been working very well for us. However I did come across one inconvenience during development that I couldn’t find any information on. When using the browser developer tools to inspect network requests, all our requests which used to have specifically named endpoints like inventory?id=1234 are now just listed as graphql.

I understand why this is the case, but was hoping for a way to include some of the POST information in the list of requests. It is cumbersome to click through a dozen POSTs to try to find the one I am looking for.

It seems likely that different browsers may have different methods of approaching this. Maybe a plugin that extends the developer tools? I mention graphql since that’s the context of my question, although I suppose this problem isn’t graphql specific

In browser developer tools, is there a way to add content from each POST request to the row?

merge result of two queries in SQL

I want to combine result of two queries in a way that it should display the result of each ID from both tables separately and . It should display first ID from both tables and then display the result of second ID. Is theer any way to do this?

Suppose I have two tables:
Table 1:
Id Name
1 ABC
2 XYZ

Table 2:

ID quantity Rate

1 30 100

2 45 800

Output should be:

1 ABC

1 30 100

2 XYZ

2 45 800

Ajustar media queries para mobile

Estou fazendo um site para testes e estou com dificuldade em como ajeitar as sections com media queries, achei que com o bootstrap já ficaria correto sem precisar ajustar na mão, pois ele já implementa os breaking points, porém não estou conseguindo, é para o mobile ficar assim.

como e para ficar

HTML:

<section class="first-section"> <div class="container">   <div class="row align-items-center">     <div class="col-lg-6 mt-4 order-lg-2">       <div class="row">         <div class="col-4">           <div class="circulo mx-auto"><img class="icon1" src="img/icon1.png"></div>         </div>         <div class="col-4">           <div class="circulo mx-auto"><img class="icon2" src="img/icon2.png"></div>         </div>         <div class="col-4">           <div class="circulo mx-auto"><img class="icon3" src="img/icon3.png"></div>         </div>         <div class="col-4 mt-2 px-5">           <p class="text-center">lorem</p>         </div>         <div class="col-4 mt-2 px-4">           <p class="text-center">lorem</p>         </div>         <div class="col-4 mt-2 px-4">           <p class="text-center">lorem</p>         </div>       </div>       <div class="row">         <div class="col-4">           <div class="circulo mx-auto"><img class="icon4" src="img/icon4.png"></div>         </div>         <div class="col-4">           <div class="circulo mx-auto"><img class="icon5" src="img/icon5.png"></div>         </div>         <div class="col-4">           <div class="circulo mx-auto"><img class="icon6" src="img/icon6.png"></div>         </div>         <div class="col-4 mt-2 px-5">           <p class="text-center">lorem</p>         </div>         <div class="col-4 mt-2 px-5">           <p class="text-center">lorem</p>         </div>         <div class="col-4 mt-2 px-5">           <p class="text-center">lorem</p>         </div>       </div>      </div>     <div class="col-lg-6 order-lg-1 box-green">       <h2>Lorem.</h2>     </div>   </div> </div> 

CSS

 .first-section{   .box-green{    background-image:linear-gradient(#96D7A7,#77D3C2);    margin-top: -5%;    height: 400px;    padding-top: 6%;    color: white;    text-transform: uppercase;    }     .circulo {    width: 100px;    height: 100px;    border: 3px #FF9F8C solid;    border-radius: 50%;  .icon1{   width: 60px;   position: absolute;   left: 35%;   top: 25%; }  .icon2{   width: 90px;   position: absolute;   left: 30%;   top: 8%; }  .icon3{   width: 60px;   position: absolute;   left: 35%;   top: 30%; }  .icon4{   width: 60px;   position: absolute;   left: 35%;   top: 15%; }  .icon5{   width: 55px;   position: absolute;   left: 35%;   top: 20%; }  .icon6{   width: 60px;   position: absolute;   left: 35%;   top: 20%; }    } 

E o resultado no mobile esta assim.

Como esta

Where to store SQL queries

Currently I store queries as such…

database_queries.py

def _select_all_where_equals(table, **kwargs):     with database_alchemy.DatabaseSession() as session:         query = session.query(table).filter_by(**kwargs).all()     return query   def _select_one_where_equals(table, **kwargs):     with database_alchemy.DatabaseSession() as session:         query = session.query(table).filter_by(**kwargs).first()     return query   def _select_everything(table):     with database_alchemy.DatabaseSession() as session:         query = session.query(table).all()     return query   def manga_select_all_with_status(status):     return _select_all_where_equals(database_models.Manga, status=status)   def manga_select_one_with_id(_id):     return _select_one_where_equals(database_models.Manga, id=_id)   def manga_select_one_with_title(title):     return _select_one_where_equals(database_models.Manga, title=title) 

I create a generic function then pass the relevant parameters based upon the table, field etc.

I then call the queries as such, database_queries.manga_select_all_with_status(self.status_dropdown.get_index())

Would it be better if I stored the queries on the database model instead? Perhaps have a inheritance to a DatabaseQuery object.

class Manga(Base):     __tablename__ = "manga"      # Auto-increment primary key     id = Column(Integer, Sequence("user_id_seq"), primary_key=True)     title = Column(String(256))     url = Column(String(256))     latest_chapter = Column(Float, default=0.0)     chapters_read = Column(Float, default=0.0)     status = Column(Integer, default=0)      def __str__(self):         return f"({self.id}, {self.title}, {self.url}, {self.chapters_read}, {self.status})" 

Porque los carousel en NGX-BOOTSTRAP ocultan el titulo de cada imagen cuando el media queries es para un pantalla pequeña?

Cuando la pantalla es menor que 768px se pierden los textos de titulo y description:

First slide label

Nulla vitae elit libero, a pharetra augue mollis interdum.

Second slide label

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Third slide label

Praesent commodo cursus magna, vel scelerisque nisl consectetur.