Hive CASE WHEN THEN ISSUE [closed] - mysql

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
Below is the code failing in Hive:
(Alias at 6:5 (END) is not recognized)
INSERT INTO WRKT_REGULATORY_COMPONE_RECLASS
select
case
when WRKT_REGULATORY_COMPONENT_FINAL.REVENUE_FLAG != 'Y'
AND WRKT_REGULATORY_COMPONENT_FINAL.EXCLUDED_FLAG = 'Y'
THEN WRKT_REGULATORY_COMPONE_RECLASS.EXECUTION_ORDER = '1'
END
FROM WRKT_REGULATORY_COMPONENT_FINAL

this one: THEN WRKT_REGULATORY_COMPONE_RECLASS.EXECUTION_ORDER = '1' is wrong
after THEN it should be literal 1 or column

Related

MySQL : How to I, join this table? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 12 months ago.
Improve this question
I have table like this, and i want to output the result like output table, can anyone tell me how to do it, in MySQL
You can use left join like so :
SELECT tb_session.SESSION AS SESSION, tb_class.CLASS AS CLASS from tb_schedul LEFT JOIN tb_session ON tb_schedule.ID_SESSION = tb_session.ID LEFT JOIN tb_schedul.ID_CLASS = tb_class.ID
Good morning, you can use LEFT JOIN
try it:
SELECT tb_session.SESSION, tb_schedul.ID_CLASS FROM tb_session LEFT JOIN tb_schedul
ON tb_session.ID = tb_schedul.ID_SESSION;

Open Json a Json field in SQL Server to table [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I have a table in SQL Server where a row contains a Json column - something like this:
ResponseText
RequestId
{"LosUnqCod":0,"LosMidId":23}
96173722
{"LosUnqCod":1,"LosMidId":5}
96173721
I want to have a table in this shape:
LosUnqCod
LosMidId
RequestId
0
23
96173722
1
5
96173721
how to open this json?
Hi every body I found my answer and want to share with anyone who has the same issue as I does
SELECT
reqTbl.LosUnqCod ,
a.RequestId
FROM [dbo].[a] CROSS APPLY
OPENJSON( dbo.a.responsetext)
WITH (
LosUnqCod nvarchar(50)
) AS reqTbl
You don't have to use OPENJSON if you only have one JSON object (not an array) per SQL row, you can use JSON_VALUE instead:
SELECT
JSON_VALUE(a.responsetext, '$.LosUnqCod') LosUnqCod,
JSON_VALUE(a.responsetext, '$.LosMidId') LosMidId,
a.RequestId
FROM [dbo].[a];

how to edit my links (sort and change by starting alphabet) in sql database [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
The community reviewed whether to reopen this question 11 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
i have a database (mysql) with links like:
mysite.com/Movies/Abajan_1080p.mp4
mysite.com/Movies/Abajan_720p.mp4
mysite.com/Movies/Abajan_480p.mp4
mysite.com/Movies/Bahman_1080p.mp4
mysite.com/Movies/Bahman_720p.mp4
mysite.com/Movies/Bahman_480p.mp4
....
i sorted my files by creating directories by alphabets (A,B,...)
so i need to change links:
mysite.com/Movies/A/Abajan_1080p.mp4
mysite.com/Movies/A/Abajan_720p.mp4
mysite.com/Movies/A/Abajan_480p.mp4
mysite.com/Movies/B/Bahman_1080p.mp4
mysite.com/Movies/B/Bahman_720p.mp4
mysite.com/Movies/B/Bahman_480p.mp4
is there a simple solution to edit database? to edit all links like that?
Thanks a lot
You can use the function SUBSTRING_INDEX() to get the filename and then concatenate the path:
UPDATE tablename
SET col = CONCAT(
'mysite.com/Movies/',
LEFT(SUBSTRING_INDEX(col, '/', -1), 1),
'/',
SUBSTRING_INDEX(col, '/', -1)
)
Replace col with your column's name.
See the demo.
Results:
col
mysite.com/Movies/A/Abajan_1080p.mp4
mysite.com/Movies/A/Abajan_720p.mp4
mysite.com/Movies/A/Abajan_480p.mp4
mysite.com/Movies/B/Bahman_1080p.mp4
mysite.com/Movies/B/Bahman_720p.mp4
mysite.com/Movies/B/Bahman_480p.mp4

Replacing null by zero [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need to write a query which need to replace email result by 0 when it's null
UPDATE tblName SET email = 0 WHERE email is null;
Use the ifnull() function:
ifnull(email,"0")
You can use the coalesce function:
SELECT COALESCE(email, '0') FROM some_table

mysql return a fixed number of queries [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have 3 mysql queries in php (one for each category/widget), all 3 queries together should output 3 * 6 = 18 results. So if one query returns less, more results from the other queries should be used.
How can i do that? Thanks.
Instantiate 2 variables , keep count of selected rows and execute query using these counters
for example this will be your first query execiton
$default = 6;
$limit= $default;
$some_result = mysql("SELECT * FROM table LIMIT $limit");
then you can use this for every query-limit
$limit = $limit - count($some_result) + $default;