Need to write where condition consists of 2 groups [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 11 months ago.
Improve this question
I want to write where condition in a SQL Server query which has following conditions:
Where paymentmode='Bank' and Status not equal to Paid
payment mode='cash' and sataus not equal to completed
How I can write these 4 condition b

We put the sets of conditions in brackets. In the following either all the conditions in the first parenthesis must be met or all those in the second.
Where
(paymentmode='Bank'
and Status <> 'Paid')
Or
(paymentmode='cash'
and status <> 'completed')

Related

How can I limit some specific numbers and return them with a title? [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 days ago.
Improve this question
I have a table in postgresql which contains scores of students and I wanna show scores less than 10 with word 'failed' and more than 10 with the word 'passed'. How can I do that using a query?
As result I want a table with two columns. First scores and second 'passed' or 'failed'.

Count without duplicates [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 last year.
Improve this question
I'd like to count column values without any duplicates.
In the given example, I'd expect the SQL query to sum up column a to 6 (every value counted once)
How about
select count(distinct a)
from table

How to compare data in 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 6 years ago.
Improve this question
I have an application which is taking data from questionnaires users are completing on a website and inputting this into a SQL Lite database.
I'm using Django and would like to display data of users who match closest by selecting similar answers.
How could this be done?
You can add multiple join conditions like this
SELECT *
FROM <table>
INNER JOIN <same table different name>
ON (condition1 OR condition2 OR condition3)

SQL Image field divided by 2 [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 6 years ago.
Improve this question
Could anyone help me on the below please?
I have a field called F1.Images and I need to divide by 2 ONLY when my other field W1.Plex is Duplex else I need to retain the F1.Images count.
Thanks Satya
Sorted Brad.
Used Case/When logic. Here's the Answer:
Case
WHEN W1.Plex = 'Duplex' then (F1.images / 2)
Else F1.images
End AS Pages

How can make auto change 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 8 years ago.
Improve this question
I want to make auto changes in SQL Server. I have a table which has a column [expires date]. Should I use a trigger or job for this? I want that SQL Server checks those dates every day, and if any of it is < DateTime.Now, it must change a column [IsPremium] of that row.
Add the following statement in your Daily running JOB, if you have. (Your question in unclear. As per my understanding I post this)
UPDATE <tablename> SET
IsPremium = 1
WHERE [expires date] < GETDATE()