Select without negative values in SQL query [closed] - sql

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
How to select needed values without negative Total values according to this query?
Second row should not be returned as the Total value is less than 0.
SELECT DealerCode, PaymentType, Total
FROM DEL_Purchases
WHERE DealerCode = 'A0686P'

select DealerCode, PaymentType, Total from DEL_Purchases
where DealerCode='A0686P' and Total > 0

Related

Converting Decimal hours to minutes 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 1 year ago.
Improve this question
I have a decimal hour (logged_hours) column and its value in my table. I want to calculate this decimal hour value into minutes in SQL Server 2012.
logged_hours
------------
08.0000
09.0000
12.0000
You can multiply by 60:
select logged_hours * 60 as logged_minutes

SQL - Get number of Product in an order and total value [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 4 years ago.
Improve this question
Current Database:
tbl_Order:
ID.........UserName........date
1..........john............march 30 2017
2..........mike............march 31 2017
tbl_Products_In_Order
Order_ID.........Qty_Purchased........UnitPrice........TotalPrice
1...............2.....................1.00.............2.00
1...............3.....................2.00.............6.00
2...............1.....................8.00.............8.00
i need the output to be:
Order_ID...UserName...date............Number_Of_Products.........Total_Qty_All
1..........John.......march 30 2017...2..........................5
2..........mike.......march 31 2017...1..........................1
Can someone help me create the SQL query?
Here is a PostgreSQL solution (but using just basic stuff, so should be same or very similar in most SQL dialects):
SELECT
Order_ID,
UserName,
date,
count(Order_ID) AS Number_Of_Products,
sum(Qty_Purchased) AS Total_Qty_All
FROM
tbl_Products_In_Order AS pio
INNER JOIN tbl_Order AS o ON pio.Order_ID = o.ID
GROUP BY Order_ID, UserName, date
ORDER BY Order_ID

update sql query in new column [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 7 years ago.
Improve this question
I have a column in which i have 'goswara no. 21/1980' i need only 21 and year from date column like this col gr=21/year(date) through sql2005 query
http://sqlfiddle.com/#!6/bf991/6
something like this?
select
right(columnname,4) as year ,
SUBSTRING ( columnname ,len(columnname) - 6 ,2 ) as result
from test

How to display two expression result in different column in oracle sql [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 8 years ago.
Improve this question
I have a table ACCOUNT(ACCOUNT_NUMBER,BRANCH_NAME,BALANCE)
Now I need to find in Oracle SQL : all accounts with balances over R.100000 receive 6 percent interest whereas all others receive 5 percent.
I need to display the balance with 6% and balance with 5% in two different column.
What is the SQL query for it?
Maybe this is what you want:
select
account_number,
case
when balance > 100000 then balance*1.06
end AS With6PercentInterest,
case
when balance <= 100000 then balance*1.05
end AS With5PercentInterest
from ACCOUNT;
Sample SQL Fiddle

postgres count customers with 2 or more orders [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 get monthly numbers of customers who made 2 or more orders. I'm not that good with postgresql so any help would be appreciated.
Table name is shop_orders
Relevant columns are 'email' - customer, 'status_code' should have value 'CONFIRMED', date - timestamp.
Thank you.
Try this:
select EXTRACT(month FROM datecolumn ) as month,email
from shop_orders
where status_code = 'CONFIRMED'
group by EXTRACT(month FROM datecolumn ),email
having count(1) >2