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 7 years ago.
Improve this question
From following 2 columns
I want to select minimum value for each 'sid'.
Output be like
S102 | 27800.00,
S101 | 90000.50,
S103 | 250000.00,
S104 | 15000.00,
S105 | 7500.75
Use group by:
select sid, min(o_amt) from orders group by sid
Related
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 5 years ago.
Improve this question
is there any options available to create a new sql table without using 'create' keyword
For example this is a table named as Emp and you create a table named as Emp_Copy
EmployeeID EmployeeName Age Gender
1001 Henry 54 Male
1002 Tina 36 Female
1003 John 24 Male
for selecting all columns
SELECT * INTO Emp_Copy FROM Emp;
for selecting some columns
SELECT EmployeeID, EmployeeName ,Age INTO Emp_Copy FROM Emp;
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 5 years ago.
Improve this question
Let's say i have a table Task_status like below:
id TaskId SubTaskId status
1 1 1 Complete
2 1 2 Complete
3 1 3 Complete
4 2 4 InProgress
5 2 5 Complete
I want to find all the taskId whose all child tasks are Complete. How can I write that query?
Use group by and having to check if the number of rows per task equal the number of rows with Complete status.
select taskId
from tbl
group by taskId
having count(*) = sum(status='Complete')
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 7 years ago.
Improve this question
I'm trying to get my code to output in the following format:
2015-05-24 19:00 | 1
2015-04-24 19:30 | 3
2015-04-24 10:39 | 51
My table
rm_id | date
1 | 1298027046
2 | 1298027100
What should I do a SQL query?
Divide the timestamps by 1800 (30 minutes * 60 seconds/minute) to get the grouping.
SELECT FROM_UNIXTIME(1800 * FLOOR(date/1800)) AS period_start, COUNT(*) AS count
FROM YourTable
GROUP BY period_start
Ok thanks. It's great. still I need to add the condition of two dates. The first parameter will be administered and the second is the first + 7 days
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 want to remove records length equal to two. Is there any direct query to remove those records? Reading raw by raw and delete take huge time. Because my database contain more than 4 million records.
ID Column1
1 abcde bgrft
2 ab
3 bgtyk
4 gh
I want to delete record 2 and 4. Because that size=2.
I'm assuming that by 'size' you mean string length
delete from mytable where length(Column1) = 2
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
For example, i have 2 tables:
Table Countries:
id Names_countries
------------------
0 United States
Table Cities
id Names_cities
---------------
0 Los Angeles
How can i create this ?
New table
all registers
-------------
United States
Los Angeles
Just use the union operator
So:
SELECT Names_countries all_registers FROM Countries
UNION
SELECT names_cities FROM Cities
See this
http://sqlfiddle.com/#!2/89ffd/3
select Names_countries from Countries
UNION
select Names_cities from Cities