473,473 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to select same column twice with different condition?

2 New Member
Hi,

I have a table which have three fields.

The three columns are:
username lastname Timestamp

Now I have to fetch all the entries for username separately which have lastname as 'Hello' and timestamp for last six months. I need both the data in separate rows.

Thanks,
Umesh
Dec 10 '10 #1
3 6952
amitpatel66
2,367 Recognized Expert Top Contributor
Can you post what you have tried so far?
Dec 10 '10 #2
Umesh Anant
2 New Member
select password from table1 where user_id = ? AND password in (SELECT password FROM table1 where user_id = ? AND TO_CHAR(password_set_date, 'dd-mon-yyyy hh24:mi:ss') < TO_CHAR(CURRENT_DATE, 'dd-mon-yyyy hh24:mi:ss') AND TO_CHAR(add_months (sysdate, -6), 'dd-mon-yyyy hh24:mi:ss') >TO_CHAR(password_set_date, 'dd-mon-yyyy hh24:mi:ss'))

I need data for last six times separately and for last six months separately!
Dec 10 '10 #3
amitpatel66
2,367 Recognized Expert Top Contributor
Can you try this:

Expand|Select|Wrap|Line Numbers
  1. select password from table1 where user_id = ? AND password in (SELECT password FROM table1 where user_id = ? AND TO_CHAR(password_set_date, 'dd-mon-yyyy hh24:mi:ss') < TO_CHAR(CURRENT_DATE, 'dd-mon-yyyy hh24:mi:ss') 
  2. UNION ALL
  3. select password from table1 where
  4. password_set_date BETWEEN ADD_MONTHS(SYSDATE,-6) AND SYSDATE
  5.  
Dec 14 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Max | last post by:
Hi, Is it possible to have different Select Expert formula for different column or Fields at once? I can't figure out how to calculate totals for different fields such as count and total of...
3
by: Eric | last post by:
Hi : From a crystal report i get a list of employee firstnames as a string into my store procedure. Why is it comming this way ? hmmmmmm it's a question for me too. ex: "e1,e2,e3" here are my...
2
by: Alex Martinoff | last post by:
I'm wondering if it's possible to have a query construct a column where the value of the column at each row is taken from another field in that same row. For example, suppose you have a table like:...
0
by: Sinan | last post by:
Hi I am using a datagrid with a Select Column and the SelectedIndexChanged event captures the values of the cells in the selected row. It works fine before sorting any column. The problem...
2
by: Volition | last post by:
I have looked around and can't find any help for my SQL problem. I have a Table which lists people peopledb. _____________ id | Name 1 | Fred 2 | Bill 3 | Bob
0
by: Greg Smith | last post by:
I would like to assign the value of a column to the text of the 'Select' column. i.e. In stead of 'Select' it would have the value in the column. Is this do-able? Any help is greatly...
4
by: Luqman | last post by:
I have populated the Child Accounts and Parent Accounts in a Grid View Control, I want to hide the Select Column of Parent Accounts, but not the Child Accounts, is it possible ? I am using VS...
4
by: sade | last post by:
I want to select a column if data starts with a specific letter OR else to select from another column instead. Something like replacing columns. For example: 1st row to read columns ID, NAME if...
1
by: John Cazaly | last post by:
I have what wouold at first seem a simple request: to create a datagrid / View or similar for an Orders table with OrdID and OrderDate fields (plus some others). I want to select OrderDaate >= From...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.