Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL synthax

Posted on 2011-04-27
6
Medium Priority
?
235 Views
Last Modified: 2012-05-11
Hello EE,

I am not sure how to do this.. :

lets say in the table we have :

ID              LineNumber             Amount

1                      1                           0
1                      2                           0
1                      3                          100
2                      1                           0
2                      2                           50


if the user in his Menu click Open...   and choose to open ID 1
I would like the query to show all the ID (even ID 2)  but (and here is my problem) because he chose ID 1 I want to show all row of ID 1 but because he didnt chose ID 2 I need to show only rows of ID 2 that are amount at 0..

so result would be like this:

1    1   0
1    2   0
1    3   100
2    1   0


(not the lineNo 2 of ID 2 because amount is > 0 )
0
Comment
Question by:PhilippeRenaud
  • 3
  • 3
6 Comments
 
LVL 9

Expert Comment

by:radcaesar
ID: 35476610
Sorry I didn't get you exact requirement. Exaplin it clearly
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 35476638
my table:

ID              LineNumber             Amount

1                      1                           0
1                      2                           0
1                      3                          100
2                      1                           0
2                      2                           50

if user choose ID 1

query result :   All rows of ID1  + rows of all other ID's where amount = 0

if user choose ID 2
query result:  all rows id2 + rows of all other id's where amount = 0
0
 
LVL 9

Accepted Solution

by:
radcaesar earned 2000 total points
ID: 35476672
Try this

select * from table1  
where (Id=1)
or (ID <>1 and Amount =0)
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 35476749
do you think its possible without sending parameter

in your code your hardcode 1  wich i understand you want me to pass a parameter
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 35476785
no i believe its not possible.
its fine thanks
0
 
LVL 9

Expert Comment

by:radcaesar
ID: 35476918
Yes you need to pass parameter.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question