my input is : And i am expecting below output: I tried using cross apply but not getting right output. Can anyone please help me? Answer UNION is the right way to solve this:
What is the default limit for auto generated primary Column(Integer) in SQLAlchemy with FastAPI and MYSQL?
Currently, I’m using Python’s fastAPI with SQLAlchemy and MYSQL. I’ve defined an auto-generated primary column as shown below. What’s the maximum number that this column can hold? Currently, the DB grows by 10k records per day, and I clear 70% of it on the weekends. The number of recor…
Need a where clause for an XML Node in a SQL Server 2019 stored procedure
I have 1.5 million XML documents stored in a SQL Server 2019 database and I need to have a where clause that has multiple nodes in a stored procedure. I need to pull all XML files where PI_ID equals 9983950. The number of PI’s in the PIS node could be one or 5. I’m using this code: when I need
how to update multiple rows in a single column to use a different time
I have a table as follows i want to increment the datetime by 1minute for each id so the outcome should look like how can i achieve this in an update statement all at once? since i have like 100 rows Answer You can use an updatable CTE: db<>fiddle
hive get percentages of count column not working
i have the following query in hive to get the counts per each of those columns (cluster, country and airline) as a percentage. But my percentage column contains only 0’s.. why/what am i doing wrong below? Answer First, you should use window functions. Second, beware of integer division. I would phrase t…
SQL – how to remove whole row if one of the column in subquery return NULL
I am stuck in 1 SQL query This query return 4 row ( As shown in the screenshot ) I want a scenario like : If subquery return NULL , then the whole row will not be shown. So in this example “childthree” should not be shown , as “parent_user_email” is NULL , so the whole 3rd row need to
Insert Query only inserting the first value?
I looked around quite a bit figuring someone else must have had this issue, but I didn’t see it. It’s driving me nuts, that something so simple isn’t working and I can’t figure out why, and so I’ve spent 3 hours now on something that should have taken a couple minutes… So h…
How to Convert Hours, minutes and seconds (HH:mm:ss) to minutes and seconds (mm:ss) in SQL
Suppose I have 2hrs, 47minutes and 10 second (02:47:10) which is in hh:mm:ss format as a value in Time column. I would like to convert it to minutes and seconds only (mm:ss). Hence the result should be 167minutes and 10 secs in sql. I have tried using the code The result was 167.166666. My desired output shou…
How to select rows from table 2 based on values in column from table 1 in SQL Teradata?
I have table in SQL Teradata: And I need to find only these clients which has their name (from column “client”) + “arg” or “por” in column “descpition” nevermind whether before or after name. So using above example I need to display only John Simon and Larry For…
How to add a Jinja function to .sqlfluff config
I’m using the jinja functions run_query and execute. https://docs.getdbt.com/reference/dbt-jinja-functions/run_query But when sqlfluff lint I get the following error: Undefined jinja template variable: ‘run_query’ I’m trying to add it to the .sqlfluff config but there doesn’t see…