I have a table with following structure Id Division Details 1 A some text 2 A some text 3 B some text 4 B some text 5 B some text I need to add a new column of integer type named “Order” with some data as described below: Id Division Details Order 1 A some text 1 2 A some
Tag: sql
how to filter data using qualify row_number in sql server [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 2 years ago. Improve this question I am trying to use QUALIFY to filter the data without seccess (in SQL SERVER) also, I do not…
Generating never used before random number in SQL
I am using the function below to generate a random number between 0 and 99999999999. However, I need to make sure that the returned number has never been used before in the same app. In .net I would create a while loop and keep looping until the returned value is not found in a table that stores previously us…
Insert into a table in another database after first deleting
I have two databases that have same tables on those. First I had to delete all the data in employee_table in Database_1. Then after that I need to insert data in the employee_table in Database_2 to the employee_table in the Database_1. I am using SQL Server Management Studio 2017. Is there any solution for th…
Using WHERE or ON to filter
Example A SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.key = table2.key WHERE table2.key IS NULL; Example B SELECT column_name(s) FROM table1 LEFT JOIN table2 ON table1.key = table2….
IlluminateDatabaseQueryException: SQLSTATE[42000]: Syntax error or access violation: 1064
i m trying to add this query into my code in laravel. it runs smoothly in phpmyadmin or with mysql command line but enable to get anything but this syntax error. my query : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your M…
Count specific information in .db file
I wish to count the number of males and females in a specific city that the user chose. Here’s a gist of the .db file: example_table CODE AGE SEX CITY —- — — —- E101 …
Conditional Inner Join with two Functions
I have two functions. I need to decide whether to join with these two based on a BIT Value. Basically if BIT=0 join with function 1 else join with function 2 I tried putting an IF Clause .. but it does not seem to work. What is the proper way to do it? Answer Just add your static condition as
SQL Get certain value form two tables and make result set multiple rows
I have two tables: I tried using the statement above but it would not work. I need the statement to return all the tables that have the word john in it. Answer You want union all:
calculating percentiles in aws athena
result of my query is being used in aws quicksight. even though quicksight offers percentileCont() which does the job for us I want to use it in the query instead of using calculated field. eventually what I want to do is create a point column where depending on a column that ranges from [a, b]. Right now I f…